Cloud Backed SQLite

Multiple prefetches on the same database?
Login

Multiple prefetches on the same database?

(1.1) By nick.tessier on 2023-08-17 16:46:18 edited from 1.0 [source]

Hi,

Would it be possible to add something like 'isPrefetching' to the bcv_database table so that we can be sure not to trigger more than one prefetch on the same database?

We don't want to give extra priority to a database just because two clients have triggered a prefetch on it, so we will use 'isPrefetching' to make sure that we don't trigger more than one prefetch. I guess the state column is a possible option as well for this.

Also open to any other suggestions you may have.

(2) By Dan Kennedy (dan) on 2023-08-17 21:04:51 in reply to 1.1 [link] [source]

Hi Nick,

Adding a column to the bcv_database table seems possible. Will get back to you.

Dan.

(3) By Dan Kennedy (dan) on 2023-08-18 20:16:00 in reply to 1.1 [link] [source]

So, this change:

https://sqlite.org/cloudsqlite/info/7712ba261154aa2d

adds two columns to the "bcv_database" table: "nclient" and "nprefetch". Column "nclient" contains the number of database clients that have the database open, and "nprefetch" contains the number of ongoing prefetch operations on the database (i.e. the number of open sqlite3_prefetch* handles).

In daemon mode, the two new columns are only present after the client has been upgraded. It is possible to use an old client with a new version of the daemon, but the two new columns will not be available.

If a new client connects to an old daemon, the columns are present, but are set to NULL instead of integer values.

Dan.

(4) By nick.tessier on 2023-08-21 14:13:49 in reply to 3 [link] [source]

Thanks!

I noticed that there is a comment /* TODO: Real values! */ on line 6255 of blockcachevfs.c, could you explain that? Is that todo still applicable?

(5) By Dan Kennedy (dan) on 2023-08-22 16:10:10 in reply to 4 [link] [source]

Thanks for reporting this. It was just an old comment I forgot to remove. Have now done so:

https://sqlite.org/cloudsqlite/info/94b1bc44c80b54e7

Dan.