The problem with that approach is that SQLite doesn't support nested
transactions. And I do have transactions which sometimes have to be rolled
back. Oh and there are multiple threads involved. I don't think it's really
good to start a transaction in one thread, add a few more from several other
threads, then finish it from yet another thread.

Laszlo Elteto
SafeNet, Inc. 

-----Original Message-----
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 19, 2006 11:30 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] delayed (batch) transactions

Laszlo Elteto wrote:
> For this particular application it would NOT be a problem to lose like 
> 2-5 seconds of transactions. I wonder if it is possible to tell SQLite 
> to "hold off" the transactions, ACCUMMULATE them until a certain time 
> (or if cache memory is exhausted - which is not yet the case as we 
> have a modest database), then make a BIG COMMIT (ie. all previous 
> transactions committed or none). That way it's still transactional 
> (ie. no currupted database - I really don't want to use sync = OFF) 
> but the I/O performance wouldnt slow down serving requests.
>
>   
Laszlo,

You should be able to do this yourself without changing the SQLite source
code.

You can create two functions to wrap the begin and end transaction
operations. You can have your begin function check for an existing
transaction and only open a new one if there isn't one open yet. It records
the start time for the transaction. The close function counts down until all
open transactions are closed. If the current time is more than your limit
after the start time, it actually closes the transaction and flushes the
changes to disk. Pseudo code is below:

begin_transaction
    if transaction open
       increment open count
    else
       open transaction
       set transaction open to true
       set transaction start time
       set open count to 1

end_transaction
    decrement open count
    if open count = 0
       if now - transaction start time > 5 seconds
          close transaction
          set transaction open to false

HTH
Dennis Cote

----------------------------------------------------------------------------
-
To unsubscribe, send email to [EMAIL PROTECTED]
----------------------------------------------------------------------------
-

The information contained in this electronic mail transmission may be 
privileged and confidential, and therefore, protected from disclosure. If you 
have received this communication in error, please notify us immediately by 
replying to this message and deleting it from your computer without copying or 
disclosing it.

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to