sqlite concurrency bulk insert

720 Views Asked by At

I read sqlLite is better for SELECT rather than for insert and especially for concurrency insert because locks the entire database file but I would like to know your last point :).

So I'm wondering if I get myself into troubles with such a thing:

foreach($rows as $row){
    if(null === $model->check($row->id,$row->name)){
        //prepare date
        $model->insert($data);
    }
}

the code is inside a gearman worker so I've more than one instance.

Thanks in advance.

2

There are 2 best solutions below

0
On BEST ANSWER

You may also want to look at Berkeley DB. The SQL API for Berkeley DB is SQLite compatible, but it has much higher concurrency because it doesn't require exclusive database write locks. Because the API is SQLite compatible, it's an easy test to rebuild your application against the Berkeley DB library.

0
On

No problem at all to me. Here's a great read regarding sqlite locks: http://www.sqlite.org/lockingv3.html