开发者

sqlite concurrency bulk insert

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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜