Jump to content

[SOLVED] JOIN Query Optimalization MySQL 5.0.27 (MyISAM tables)


Linvo

Recommended Posts

Hello,

I'm studying optimalization of MySQL queries, this time the SELECT query with the use of joins.

I'v attached a word document with the result of an explain of a select query with the use of LEFT JOIN and the WHERE part.

I like to have some critic/remarks how this query is formulated. Maybe there are alternatives.

Thanks for reply's.

[attachment deleted by admin]
This query appears to be long and took a while to get thru.

The only improvment that I see is reducing the redundancies in the under WHERE condition:
for instance, this part:
LEFT JOIN hoofdafdeling ON afdeling.hoofdafdeling_id=hoofdafdeling.id LEFT JOIN unit ON hoofdafdeling.unit_id=unit.id

is already have the condition "hoofdafdeling.unit_id=unit.id"
and therefore you do not need to repeat it under WHERE.

You have a quite a few of this issues.
Thanks for your reply HVLE,

I've omitted the redundancies and made the query more readable.
See the attached doc.

Furthermore, I changed the LEFT JOIN in JOIN because I'm not interested in records with the NULL value.

Maybe there's more to optimize?



[attachment deleted by admin]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.