It takes about 6 seconds to insert 100 records into a sqlite db on my
Linux x64 system. Is sqlite normally that slow?
Thanks,
Tadhg
Here is the code I used:
USING: db db.sqlite db.tuples db.types ;
TUPLE: sqltest id ;
sqltest SQLTEST {
{ id ID +db-assigned-id+ }
} define-persistent
:
Because sqlite implicitly starts a new transaction for each insert.
Modify it to wrap all inserts in single transaction and see the
difference, like this:
: insert-test ( -- )
[
sqltest recreate-table
begin-transaction
100 [ sqltest new
Oh, realized there is with-transaction word only after sending the message.
So it becomes
: insert-test ( -- )
[
sqltest recreate-table
[ 100 [ sqltest new insert-tuple ] times ] with-transaction
] with-sqltest-db ;
On Fri, 22 Apr 2011 03:52:46
That's great. It takes 0.3 seconds now. Thanks for the help.
On 21 April 2011 22:59, Andrey Onymov anonym...@gmail.com wrote:
Oh, realized there is with-transaction word only after sending the message.
So it becomes
: insert-test ( -- )
[
sqltest recreate-table