【发布时间】:2019-10-02 10:06:24
【问题描述】:
我有一个动态生成的 sqlite 查询,例如:
SELECT * FROM gsmr_data WHERE test_id='86' AND device='devicename' AND id<4371808 AND (metric='C2' OR metric='C2_N1' OR metric='C2_N2' OR metric='C2_N3' OR metric='C2_N4' OR metric='C2_N5' OR metric='C2_N6') ORDER BY id DESC LIMIT 500
其中 id 基于最后一个结果,而指标(在 OR 部分中)是动态添加的。
我的桌子是这样的:
我在表中有以下索引:
查询需要很长时间(在 sqlite db 浏览器中为 7 秒)
还有什么可以提高查询速度的吗?
【问题讨论】:
标签: sql performance sqlite