Jump to content

Query Preformance


tobeyt23

Recommended Posts

Anyway I can speed this up possible with a UNION, i tried but seem to be missing something?

 

SELECT 
xfiles.id, xfiles.user_id, xfiles.action, xfiles.other_action, xfiles.document, xfiles.start_date, xfiles.end_date, user_profiles.fname, user_profiles.mname, user_profiles.lname, licenses.number, licenses.state, asc_records.fname, asc_records.mname, asc_records.lname, asc_records.st_abbr, asc_records.lic_number, asc_records.status 
FROM xfiles 
LEFT JOIN user_profiles ON xfiles.user_id = user_profiles.user_id LEFT JOIN licenses ON xfiles.user_id = licenses.user_id AND xfiles.license_id = licenses.id
LEFT JOIN asc_records ON xfiles.asc_id = asc_records.id 
WHERE xfiles.deleted=0 AND licenses.state = 'FL' OR asc_records.st_abbr = 'FL'

Link to comment
Share on other sites

Here you go:

 

id,select_type,table,type,possible_keys,key,key_len,ref,rows,Extra

1,SIMPLE,xfiles,ALL,,,,,3653,

1,SIMPLE,user_profiles,ALL,,,,,1226,

1,SIMPLE,licenses,eq_ref,PRIMARY,PRIMARY,4,cb_overall.xfiles.license_id,1,

1,SIMPLE,asc_records,eq_ref,PRIMARY,PRIMARY,4,cb_overall.xfiles.asc_id,1,Using where

 

Link to comment
Share on other sites

  • 4 weeks later...

You're mixing AND and OR -- probably not how you expect -- you're missing parentheses.  IN() solves this nasty oversight.

 

Also, assuming your 'deleted' column is rare, an index on that column might help too, since now EXPLAIN shows 'all' for the `xfiles` table.

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.