database - MySQL Query Optimization -


i have following query select users , locations, etc mysql (all innodb). table user, blocked_user , blocked_countries have 2mil rows each, countries 250, regions 3500 , cities 2.8mil.

the problem query quite fast (0.05sec) without and co.country_id='us' in where clause. however, tried around have feeling there must easier , better way query, no?

what missing? highly appreciated! thank in advance!

thank again help. finally, i've found direction solve problem. performance problem caused because of mixture between range scan , order ... limit.

so, i've learned lot (new me) indexing , found if have range scan (as in case age between x , y), ranging column must last in concatenated index, otherwise index cannot used entirely. in addition, column used sort results, must last in index. so, given mixture between range scan , order by, need decide if index should used sort or select.

in case means thinking of combinations several indexes, left on rows sorted few or if search cannot narrowed down rows, separate index used sorting query find number of rows given limit.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -