transaction during reading on read-only database

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

transaction during reading on read-only database

andrii.motsok
Hi,


My understanding is that any reading from database automatically starts read transaction. The question: why does sqlite need to do it on read-only database?


Regards,

Andrii
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: transaction during reading on read-only database

Dominique Pellé
Andrii Motsok <[hidden email]> wrote:

> Hi,
>
>
> My understanding is that any reading from database automatically
> starts read transaction. The question: why does sqlite need to do it on read-only database?
>
>
> Regards,
>
> Andrii

You may open a database as read-only, but another process can open it
as read-write.  So SQLite needs to check the lock even when the DB
is opened as read-only.

Now if the database is on a read-only file system, it is possible to
tell SQLite by
opening with file:foo.sqlite?immutable=1  (see https://www.sqlite.org/uri.html)
and that can save some time. But make sure to read the caveats at above URL.

Regards
Dominique
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: transaction during reading on read-only database

KlaasV
In reply to this post by andrii.motsok
Ciao Andri,

To keep the results of a query consistent one better starts a transaction. A database can be updated by one thread at a time, but read by many.
Suppose you need a list of all employees of a department. If you start to search one at a time a lot of changes can happen. An employee can be moved to another department, fired or a new one entered. Another reason is speed. All (or most if it is a huge department and/or a tiny cache) employees are in cache so you're sure you have the requested list showing the situation on the moment of creation.

Andrii Motsok wrote Thu, 6 Oct 2016 11:43:10:

>My understanding is that any reading from database automatically starts read transaction.
>The question: why does sqlite need to do it on read-only database?


Kind regards | Vriendelijke groeten | Cordiali saluti,
Klaas `Z4us` van Buiten V, Experienced Freelance ICT-Guy
https://www.linkedin.com/in/klaas-van-buiten-0325b2102
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Klaas "Z4us" V, MetaDBA at InnocentIsArt.EU