![](/img/trans.png)
[英]mysql - group by indexed columns + where by indexed column caused speed decrease
[英]select speed on indexed column mysql
我在具有4.5ish百萬行的innodb上有一個mysql表。
為什么這些(幾乎對我來說)幾乎相同的選擇語句之間存在巨大的時差?
url
是varchar(200)
select * from table where url = 12345; take 2.715 seconds
select * from table where url = "12345"; takes 0.000 seconds
提前致謝
我認為您會發現以下啟發性的信息。
https://bugs.mysql.com/bug.php?id=32308
http://dev.mysql.com/doc/refman/5.0/en/type-conversion.html
值得注意的是,文檔明確指出(強調我的意思):
為了將字符串列與數字進行比較, MySQL無法使用該列上的索引來快速查找值 。 如果str_col是索引字符串列,則在以下語句中執行查找時不能使用索引:
SELECT * FROM tbl_name WHERE str_col=1;
這樣做的原因是有許多不同的字符串可以轉換為值
1
,例如'1'
,' 1'
或'1a'
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.