Jump to content

Is it possible to create indexes in mysql across two tables?


Recommended Posts

Hello,

 

I have the following sql query which joins two tables.

 

SELECT * FROM research_job_searches_results INNER JOIN geocodes ON research_job_searches_results.research_job_searches_results_company_location_description = geocodes.geocode_location WHERE (geocodes.geocode_latitude < '26.090402914763' AND geocodes.geocode_latitude > '25.367567085237' AND geocodes.geocode_longitude < '-79.876001085237' AND geocodes.geocode_longitude > '-80.598836914763') ORDER BY research_job_searches_results.research_job_searches_results_index DESC LIMIT 0, 100

 

To speed things up I'd like to set up an index made up of all the columns that have conditions specified in the query:

research_job_searches_results.research_job_searches_results_company_location_description

research_job_searches_results.research_job_searches_results_index

geocodes.geocode_latitude

geocodes.geocode_location

geocodes.geocode_longitude

 

Please could you tell me if it is possible to create an index that covers 2 tables?

 

Or should I create two indexes, i.e. one for each table? ... i.e. one index for:

research_job_searches_results.research_job_searches_results_company_location_description

research_job_searches_results.research_job_searches_results_index

 

and another index for...

geocodes.geocode_latitude

geocodes.geocode_location

geocodes.geocode_longitude

 

Many thanks,  :)

 

Stu

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.