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 insert-tuple ] times
              commit-transaction
          ] with-sqltest-db ;

On Fri, 22 Apr 2011 03:06:36 +0600, Tadhg O'Meara <tome...@gmail.com>
wrote:

> 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
> : with-sqltest-db ( quot -- )
>     "sqltest.db" <sqlite-db> swap with-db ; inline
> : insert-test ( -- )
>     [
>         sqltest recreate-table
>         100 [ sqltest new insert-tuple ] times
>     ] with-sqltest-db ;
> [ insert-test ] time

------------------------------------------------------------------------------
Fulfilling the Lean Software Promise
Lean software platforms are now widely adopted and the benefits have been 
demonstrated beyond question. Learn why your peers are replacing JEE 
containers with lightweight application servers - and what you can gain 
from the move. http://p.sf.net/sfu/vmware-sfemails
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to