Large number of SQLite inserts using PHP

前端 未结 4 1314
无人共我
无人共我 2021-01-13 01:54

I have about 14000 rows of comma separated values that I am trying to insert into a sqlite table using PHP PDO, like so:



        
4条回答
  •  深忆病人
    2021-01-13 02:37

    From SQLlite FAQ :

    Transaction speed is limited by disk drive speed because (by default) SQLite actually waits until the data really is safely stored on the disk surface before the transaction is complete. That way, if you suddenly lose power or if your OS crashes, your data is still safe. For details, read about atomic commit in SQLite.. [...]

    Another option is to run PRAGMA synchronous=OFF. This command will cause SQLite to not wait on data to reach the disk surface, which will make write operations appear to be much faster. But if you lose power in the middle of a transaction, your database file might go corrupt.

    I'd say this last paragraph is what you need.

    EDIT: No sure about this, but I believe using sqlite_unbuffered_query() should do the trick.

提交回复
热议问题