Mike,




"mike cariotoglou" <[EMAIL PROTECTED]>
08/10/2004 11:16 AM
Please respond to sqlite-users

 
        To:     <[EMAIL PROTECTED]>
        cc: 
        Subject:        Re: [sqlite] Is this an in-memory database too


> assume that I can live with the database being in a high-risk state, for 
a
> small window of time.  I would like to be able to do this:
> pragma synchronous=off
> ....
> ... inserts,updates,deletes
> pragma synchronous=full
> this I *can* do, now, but I dont think that this sequence will flush the
> in-memory caches when it ends. so, if the pragma did this automatically, 
the
> above sequence would make sense. Is this something you could/would add ?
> alternatively, a PRAGMA FLUSH statement would be fine,too.

It would usually make more sense to do the following:

BEGIN TRANSACTION;
... inserts,updates,deletes
COMMIT;

You get pretty much the same affect, but it is safe. Setting 
synchronous=off doesn't handle things safely in the event of power failure 
(although as I understand it, it does still protect against your process 
crashing). Transactions do handle power failure safely. Are you just 
trying to avoid having the database locked for the duration of your 
changes?

If that is the case, perhaps you could prepare your changes elsewhere 
before applying them in one hit to the database. Perhaps you could even 
work between two databases. Update a "working" database for the eager 
processes, but periodically commit all changes to the "backup" database. 
On startup, copy your backup database over the top of your working 
database to guarantee consistenecy.

Benjamin.

Reply via email to