What is the most efficient way to RESET an SQLite Table
This question already has an answer here:
This is something of a general answer to a general question, but one of these solutions may be useful for you:
DELETE FROM [table]
is too slow, try using TRUNCATE TABLE
. It may be much faster; it has been so for me in certain scenarios. You'll have to benchmark it for your own situation, though. If all of those are too slow, the performance issue may be caused by the amount of time it takes to talk to the persistent storage used by your database. In that case, you have a few other options:
searchable_coins_489
(and tell code that writes to the table the new name), then you can "fork and forget" the deletion: create a new thread, issue a DROP TABLE
in it, and then forget about it (don't wait for it to complete) in your main thread. Since the database is backed by the same files, this may not yield quite the same performance benefits as it would if there were a multiprocess remote database, but it may help your situation some--especially if you're in WAL mode. Again, benchmarking is key here. 上一篇: 为什么“while(!feof(file))”总是错的?
下一篇: 什么是重置SQLite表的最有效方法