以下查詢引發「無查詢解決方案」。 AAA1是包含en_meros, en_ref, en_se
sqlite:「無查詢解決方案」覆蓋索引當列!=「東西」
SELECT en_family
FROM entries INDEXED BY aaa1
WHERE (en_meros<>6) AND (en_ref=0) AND (en_se=1) AND (en_lect LIKE "% abcd%" OR en_lect LIKE "abcd%")
如果我改變en_meros<>6
到en_meros=6
然後它的索引,但我在尋找不相等。
如果我不使用任何索引,則查詢速度很慢(〜500 ms)。
如果我使用的列個別指標en_ref或en_se,它仍然是400毫秒〜
我應該怎麼辦?我該如何解決這個問題?
預先感謝您。
編輯:表的模式是:
CREATE TABLE [entries] (
[en_id] INT,
[en_lect] TEXT(4096),
[en_example] TEXT(4096),
[en_opref] INT,
[en_meros] INT,
[en_main] INT,
[en_header] INT,
[en_se] INT,
[en_atono] TEXT(4096),
[en_family] INT,
[en_ref] INT,
[en_lectlexi] TEXT(4096),
[en_thama] TEXT(4096),
[en_meros2] INT);
CREATE INDEX [aaa1] ON [entries] ([en_meros], [en_ref], [en_se], [en_lect]);
CREATE INDEX [en_atono1] ON [entries] ([en_atono]);
CREATE INDEX [en_family1] ON [entries] ([en_family]);
CREATE INDEX [en_header1] ON [entries] ([en_header]);
CREATE UNIQUE INDEX [en_id1] ON [entries] ([en_id]);
CREATE INDEX [en_lect_en_ref1] ON [entries] ([en_lect], [en_ref]);
CREATE INDEX [en_lect1] ON [entries] ([en_lect]);
CREATE INDEX [en_main1] ON [entries] ([en_main]);
CREATE INDEX [en_meros1] ON [entries] ([en_meros]);
CREATE INDEX [en_meros21] ON [entries] ([en_meros2]);
CREATE INDEX [en_opref1] ON [entries] ([en_opref]);
CREATE INDEX [en_ref1] ON [entries] ([en_ref]);
CREATE INDEX [en_se1] ON [entries] ([en_se]);
CREATE INDEX [en_thama1] ON [entries] ([en_thama]);
CREATE INDEX [en_meros2_en_lect] ON [entries] ([en_meros2], [en_lect]);
也許是因爲'en_meros <> 6'的行數多於'en_meros = 6'的行數,因此需要時間來獲取這些行? –
MySQL和SQLite是兩種不同的rdbms產品。請只使用相關的產品標籤。 – Shadow
盲目進行隨機更改沒有用。顯示數據庫模式。 –