> You need to add your records in smaller batches and sleep just a
little between iterations.
>  
> Your batches will have to be small enough to make the user response
time reasonable.
>  
> You'll find that your loop of inserting records won't take long.  It's
when you do the "COMMIT" that it locks everything and takes all the time
to write to disk.
>  
> Something like this to  COMMIT in batches:
>  
> while(records) {
>   insert records
>   if (recnum%10000)==0 COMMIT;BEGIN DEFERRED } COMMIT
>  

Thanks Michael, that's what I thought.  I have tried this and it did
improve things considerably.  What I've got now is a mutex check between
each record insert, and if the second process is waiting on the mutex I
then in the first process I do a commit, then wait on the mutex in the
1st process until the second process has finished then carry on with the
inserts.  Seems to be faster doing it this way (though not by much).
I've got the delay in the second process down to around 200ms which is
much improved from the original delay of over a minute. :)

Thanks all,
Nick.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to