Bug #60691 LIMIT 1 WITH UNION
| Submitted: | 29 Mar 2011 15:49 | Modified: | 29 Mar 2011 18: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: | limit, qc, UNION | ||
[29 Mar 2011 15:49]
Roberto Spadim
[29 Mar 2011 15:57]
Valeriy Kravchuk
Probably you need UNION ALL then, not UNION... See bug #20302 and bug #17842 for similar feature requests and related worklog number.
[29 Mar 2011 16:00]
Valeriy Kravchuk
If UNION ALL will work for you, there is a bug report already in progress that (after being fixed) may help in your case also, Bug #50674.
[29 Mar 2011 16:08]
Valeriy Kravchuk
See Bug #58924 also :)
[29 Mar 2011 17:46]
Roberto Spadim
nice i´m testing union all, just some minutes...
[29 Mar 2011 17:47]
Roberto Spadim
didn´t work 18 seconds, if only run query 1 it get 0,1 seconds (others queries are very slow i know, it´s near a table scan) explain result: "id","select_type","table","type","possible_keys","key","key_len","ref","rows","Extra" "1","PRIMARY","A","const","PRIMARY,lote","PRIMARY","77","const","1","" "2","UNION","B","range","PRIMARY,lote","PRIMARY","77",NULL,"4","Using where" "3","UNION","C","ref","PRIMARY,lote","lote","4","const","705793","Using where" "4","UNION","D","ref","PRIMARY,lote","lote","4","const","705793","Using where" "5","UNION","E","ref","lote","lote","4","const","705793","Using where" "6","UNION","F","ref","lote","lote","4","const","705793","Using where" "7","UNION","G","ref","lote","lote","4","const","705793","Using where" NULL,"UNION RESULT","<union1,2,3,4,5,6,7>","ALL",NULL,NULL,NULL,NULL,NULL,""
[29 Mar 2011 18:18]
Roberto Spadim
BUG 58924 seens a bit confusing, i don´t know if he/she want limit the first select, the second, or the result of union BUG 50674 seens to a algorithm selection, temp table have some pros and cons, nothing to do here, maybe a SQL option SQL_SMALL_RESULT or SQL_BIG_RESULT could help optimizer to choose between temp table or not, i prefer temp table today, in my opnion BIG UNIONs aren´t fast, a temporary table and after a select is better MY BUG IS DUPLICATED OF BUG 20302, I WILL CLOSE IT (the problem continue in 5.5) BUG 17842 could be better optimized with PARTITION engine with different engines using partition prune (i don´t know if UNION is a good choise) the idea here is the union (union all could work too) thanks ! :) mark as duplicated of BUG 20302 please
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.047 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.