Why do you think you're using a UNION in your query? The keyword UNION doesn't appear anywhere in your query. You don't even have a second query being UNIONed to the first. All you've got is a pair of parentheses surrounding your original query, which seems to perform okay.
For what it's worth, I don't see why a pair of parentheses would change the performance but calling it a UNION just confuses the issue, in my view. Rhino ----- Original Message ----- From: "Kevin Burton" <[EMAIL PROTECTED]> To: <mysql@lists.mysql.com> Sent: Monday, June 27, 2005 4:17 PM Subject: Why would a UNION be 100x slower than the same SELECT... > Here's a big problem I'm having. > > If I have a query like: > > SELECT * FROM FOO WHERE FOO.LAST_UPDATED < 1119898418779 AND > FOO.FEED_ID = 1 ORDER BY FOO.LAST_UPDATED DESC LIMIT 10 > > it only takes about 10ms or so to execute. > > but... if I rewrite it to wrap it in a union like so: > > ( SELECT * FROM FOO WHERE FOO.LAST_UPDATED > < 1119898418779 AND FOO.FEED_ID = 1 ORDER BY FOO.LAST_UPDATED DESC LIMIT > 10 ) ORDER BY LAST_UPDATED DESC LIMIT 10 > > then its 100x slower and takes about 1000ms > > No tmp disk tables were created (or at least thats what show status is > telling me). > > Any idea whats going on and how I could fix this? > > Kevin > > -- > > > Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com. > See irc.freenode.net #rojo if you want to chat. > > Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html > > Kevin A. Burton, Location - San Francisco, CA > AIM/YIM - sfburtonator, Web - http://peerfear.org/ > GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412 > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > > > -- > No virus found in this incoming message. > Checked by AVG Anti-Virus. > Version: 7.0.323 / Virus Database: 267.8.2/29 - Release Date: 27/06/2005 > > -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.8.2/29 - Release Date: 27/06/2005 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]