Bastian Albers

Januar 11, 2010

MySQL: MAX_JOIN_SIZE resolution

Abgelegt unter: Uncategorized — Tags:, , — Bastian Albers @ 10:37 pm

Jus in case you ever get this error message:

1104: The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok

Let me spare you a possible long search for a solution and no, you don’t have to switch to a different webhost: just try to index some foreign keys in your tables and see if it works. If you do that MySQL does not search the whole table for the linked row. So let’s say table1 has 100 rows where each one has a linked row of table2 through a foreign key foreign_key. So if you do a query like this:

SELECT * FROM table1 LEFT JOIN table2 ON table1.foreign_key = table2.id

mysql does not search all rows of table2 a 100 times. Let me explain again: without an index on foreign_key, if table2 has 1000 rows, mysql searches through 1000 rows 100 times. Put an index into the game and you’ll have 1000 times 1 index lookup.

Keine Kommentare »

Es gibt noch keine Kommentare.

RSS-Feed für Kommentare zu diesem Artikel. TrackBack-URL

Einen Kommentar hinterlassen

Powered by WordPress ( WordPress Deutschland )