SQLite: COUNT slow on big tables

前端 未结 8 2040
不知归路
不知归路 2021-02-02 07:43

I\'m having a performance problem in SQLite with a SELECT COUNT(*) on a large tables.

As I didn\'t yet receive a usable answer and I did some further testing, I edited m

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-02 08:03

    If you haven't DELETEd any records, doing:

    SELECT MAX(_ROWID_) FROM "table" LIMIT 1;
    

    Will avoid the full-table scan. Note that _ROWID_ is a SQLite identifier.

提交回复
热议问题