Home » Performance » MySQL » Simple LEFT JOIN still uses file sort
Simple LEFT JOIN still uses file sort [message #551] Mon, 08 January 2007 19:28 Go to next message
Niels  is currently offline Niels
Messages: 2
Registered: January 2007
Junior Member
Hi!

I'm using a very simple JOIN:

SELECT *
FROM A
LEFT JOIN B ON A.pointer=B.id
ORDER BY A.id;

EXPLAIN tells me it uses file sort. There are indexes on all fields. The problem is the ORDER, but I don't fully understand why this situation causes problems.

I use this kind of query a lot in a webapp I'm doing, and for small tables it's fine. But with 100k records in A and B, it becomes unusable. Maybe I could fine tune a cache or two, but that doesn't really solve the problem. Can it really be that it's impossible to do this without file sort?


Thanks,
Niels
Re: Simple LEFT JOIN still uses file sort [message #558 is a reply to message #551 ] Tue, 09 January 2007 11:18 Go to previous messageGo to next message
Peter  is currently offline Peter
Messages: 405
Registered: August 2006
Senior Member
Super Guru
26

This query basically looks up a value which is located in a range between 2 values in one record.

----------------------------------------------------

Any ideas how to speed it up?

Thanks!I'm just q


Peter Zaitsev, MySQL Performance Expert
MySQL Performance Blog - http://www.mysqlperformanceblog.com
MySQL Consulting http://www.mysqlperformanceblog.com/mysql-consulting/
Re: Simple LEFT JOIN still uses file sort [message #575 is a reply to message #558 ] Wed, 10 January 2007 15:16 Go to previous messageGo to next message
Niels  is currently offline Niels
Messages: 2
Registered: January 2007
Junior Member
----+-------------+-------+------+----------------+-------- --------+---------+---------------------+--------+---------- ---+
| 1 | SIMPLE | avtal | ALL | PRIMARY | NULL | NULL | NULL | 34 | Using where |
| 1 | SIMPLE |
Re: Simple LEFT JOIN still uses file sort [message #576 is a reply to message #575 ] Wed, 10 January 2007 16:12 Go to previous message
Peter  is currently offline Peter
Messages: 405
Registered: August 2006
Senior Member
Super Guru
V | ref | Index__avtalid | Index__avtalid | 5 | carro.avtal.avtalid | 138929 | Using where |
+----+-------------+-------+------+----------------+-------- --------+---------+---------------------+--------+---------- ---+
2 rows in set (0.00 sec)
This query takes 15 s


If I ig


Peter Zaitsev, MySQL Performance Expert
MySQL Performance Blog - http://www.mysqlperformanceblog.com
MySQL Consulting http://www.mysqlperformanceblog.com/mysql-consulting/
Previous Topic:When (not) to group indexes: multi-column primary indexes
Next Topic:Query Speed Help
Goto Forum:
  


Current Time: Thu Jul 9 20:57:46 EDT 2009

Total time taken to generate the page: 0.01124 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.