On Mon, Sep 29, 2008 at 03:44:46AM -0700, devesh tiwari scratched on the wall:
> Hi all,
> When I used sqlite to store data, I discovered that writing/reading
> data using sqlite is vary slow as compared to direct reading/writing
> file(in my case 10 times slower).
>
> I wonder if sqlite is really slow or i am missing something at my end.
>
> Does sqlite does any caching of frequently used data or only relies
> on OS caching?
SQLite does have an internal page-cache. The default cache size is
2000 pages, the default page size is 1K. You can increase the size
of the cache (or page size) using PRAGMA commands:
http://www.sqlite.org/pragma.html
The most likely reason you are seeing a performance difference vs.
flat files is not read/writes, but writes in specific. SQLite does
not cache "dirty" pages and blocks on writes until (as best as it can
tell) the data has been fully written to disk. This by-passes the OS
write buffers and can make the write process much slower. You can turn
this off, so that writes are not blocked, but you risk transaction and
database corruption in the case of a process or systems failure.
The end result is that SQLite will be slower compared to simple,
small, flat files, but SQLite will provide a *much* higher level of
data and transaction integrity.
-j
--
Jay A. Kreibich < J A Y @ K R E I B I.C H >
"Our opponent is an alien starship packed with atomic bombs. We have
a protractor." "I'll go home and see if I can scrounge up a ruler
and a piece of string." --from Anathem by Neal Stephenson
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users