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]
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.