SQLite Forum

Regarding Application Defined Page Cache.
Login

Regarding Application Defined Page Cache.

(1) By Vijay (Vijay_123) on 2022-01-17 13:55:53 [link] [source]

Hi team ,

I am trying to understand the concept of application defined page cache. As i have seen when we try to use traditional approach of reading the database it take some longer cycles as it reads data from disk. But what i have understood from application defined page cache is that it is much faster when compared to traditional read operation as it uses fetch operation to read values from database.

can i know the exact way to implemet this application defined page cache? Any suitable example or steps to implemets this functionality would be very helpful.

Thanks in advance.

(2) By Gunter Hick (gunter_hick) on 2022-01-17 15:33:48 in reply to 1 [link] [source]

There is no speed to be gained here. The ADPC is just a method of organising the memory used to hold pages from a database file. SQLite still has to read from and write to the database file. SQLite does a great job of caching pages with the built in page cache.

(3) By Vijay (Vijay_123) on 2022-01-18 04:10:16 in reply to 2 [link] [source]

Hi,

Can you please let me know any suitable example on ADPC? Any links for examples will be helpful.

Thanks in advance.

(4) By Keith Medcalf (kmedcalf) on 2022-01-18 05:06:28 in reply to 3 [link] [source]

This may be helpful.

https://www.google.ca/search?q=principles+of+cache+design

There exists a great volume of data regarding cache design and efficiency dating from the early 1940's to today.

(5) By Vijay (Vijay_123) on 2022-01-18 09:30:52 in reply to 3 [link] [source]

Hi,

I want an example implementation of Application Defined Page Cache using c++. Please let me know if there is any example implementation in any language.

Thanks in advance.

(6) By Kees Nuyt (knu) on 2022-01-18 14:22:15 in reply to 5 [source]

It is unclear what the context of your question is, so you will not get many answers. I can only guess you are referring to 7. Configuring SQLite

I think, in SQLite, an Application Defined Page Cache would replace the page cache that is provided by the sqlite library itself.

That cache is implemented in C, and you can find it in the SQLite source tree. Most users of SQLite see no reason to replace that cache.

Start your research by reading the architecture documentation on https://sqlite.org/, then investigate src/pcache.c and src/pcache1.c , and come back here with more concrete questions, if you still have any.

A web search with the keywords you used yourself offers quite a few interesting hits, even more if you leave out "application defined".

-- 
Regards,
Kees Nuyt

(7) By Gunter Hick (gunter_hick) on 2022-01-19 07:11:29 in reply to 5 [link] [source]

The Application Defined Page Cache was introduced in release 3.6.6 dating from 2008.

If this would magically speed up database reads, everybody would be using it. If everybody was using it, SQLite Development would surely have updated the internal page cache to work the same way during the last 14 years. They did not, so it does not.

The much faster fetch operation you are referring to is to retrieve a pointer to the content of a page that has already been read from the database file and stored in the page cache. The page cache neither knows nor cares about which file and where within that file it came from.

The use case for the ADPC is when SQLite is built for a system with specific memory constraints.