Bug #63167 | MAYBE a not optimized IN operation | ||
---|---|---|---|
Submitted: | 9 Nov 2011 18:17 | Modified: | 11 Nov 2011 15:18 |
Reporter: | Roberto Spadim (Basic Quality Contributor) | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S5 (Performance) |
Version: | 5.5 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | qc |
[9 Nov 2011 18:17]
Roberto Spadim
[11 Nov 2011 8:13]
Valeriy Kravchuk
OK, you had sent table structure and SELECT. But what is the real problem? You get result that is incorrect or non-optimal plan is produced?
[11 Nov 2011 12:00]
Roberto Spadim
not optimal result plan it get a full table scan, instead of index scan i think (must test) that for more than X rows inside IN () it convert a index scan to a table scan, i will test some results to know what is this size
[11 Nov 2011 12:08]
Roberto Spadim
hummm check... explain select * from est_mov where (unidade_id,lote_tipo,lote_spa,item_id,item_id_red,mov_id,oe_tipo,oe,oe_seq,table_partition) in ( ("1001","i","0.0","67","105","0010547878192","tr","43850","1","0"), ("1001","i","0.0","67","105","0010547978977","tr","43821","1","0") ) ===== Using where,15634311 (rows),SIMPLE (select type),est_mov,ALL (type) explain select * from est_mov where (unidade_id,lote_tipo,lote_spa,item_id,item_id_red,mov_id,oe_tipo,oe,oe_seq,table_partition) in ( ("1001","i","0.0","67","105","0010547878192","tr","43850","1","0") ) ===== SIMPLE (select type),est_mov,const (type),PRIMARY,63(key length),(const,const,const,const,const,const,const,const,const,const),1 (rows) well i think IN () with 1 row, is the same as =(), and IN () with more than 1 rows, isn´t optimized as "((fields)=(values) or (fields)=(values) or (fields)=(values))" (maybe because partitions?)
[11 Nov 2011 12:13]
Roberto Spadim
this (or rewrited) is more optimized: explain select * from est_mov where (unidade_id,lote_tipo,lote_spa,item_id,item_id_red,mov_id,oe_tipo,oe,oe_seq,table_partition) = ("1001","i","0.0","67","105","0010547878192","tr","43850","1","0") or (unidade_id,lote_tipo,lote_spa,item_id,item_id_red,mov_id,oe_tipo,oe,oe_seq,table_partition) = ("1001","i","0.0","67","105","0010547978977","tr","43821","1","0") ==== SIMPLE(select_type),est_mov,range(type),primary(key),63(key length), ref=null, rows=2, extra = using where
[11 Nov 2011 12:34]
Roberto Spadim
hi i rewrote with the OR clause, check the results: id,select_type,table,type,possible_keys,key,key_len,ref,rows,Extra 1,SIMPLE,est_mov,range,PRIMARY,lote,oe,item,ponto_movimentacao,rastro_mov_id,transferencias,estoque,giro,rastro_mov_id,30,NULL,1828,Using where rows :1828,Using where very better, that´s what i want, but IN () can´t optimize like many ORs
[11 Nov 2011 15:08]
Valeriy Kravchuk
How is this different from reports like bug #31188 or bug #46288 then? I think this is a 100% duplicate of bug #31188.
[11 Nov 2011 15:16]
Roberto Spadim
yes duplicated, could you mark it? thanks
[11 Nov 2011 15:18]
Valeriy Kravchuk
Duplicate of bug #31188.