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
https://forums.phpfreaks.com/topic/238208-query-preformance/
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
https://forums.phpfreaks.com/topic/238208-query-preformance/#findComment-1224424
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
https://forums.phpfreaks.com/topic/238208-query-preformance/#findComment-1235283
Share on other sites

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.