sqlite - How to solve a bottleneck on sqlite3? -
i'm working on project written in c generates 350k sequences persisted on sqlite database. each sequence have insert (or ignore) string in table , update row in other table.
i tried this "guide" couldn't reach more 30k operations per second.
i'm using transactions of 1m operations each (inserts , updates) , pragma synchronous=off
what options have solve bottleneck?
actually, sqlite 50,000 or more insert statements per second on average desktop computer. few dozen transactions per second. transaction speed limited rotational speed of disk drive. transaction requires 2 complete rotations of disk platter, on 7200rpm disk drive limits 60 transactions per second.
transaction speed limited disk drive speed because (by default) sqlite waits until data safely stored on disk surface before transaction complete. way, if lose power or if os crashes, data still safe. details, read atomic commit in sqlite..
by default, each insert statement own transaction. if surround multiple insert statements begin...commit inserts grouped single transaction. time needed commit transaction amortized on enclosed insert statements , time per insert statement reduced.
another option run pragma synchronous=off. command cause sqlite not wait on data reach disk surface, make write operations appear faster. if lose power in middle of transaction, database file might go corrupt.
please check out faq, explains insert bottleneck issue among others.
Comments
Post a Comment