Jump to content

using different index types


stubarny

Recommended Posts

$sql_query_1 = "select * from ( SELECT title, body, post_timestamp FROM ads_live WHERE MATCH(title, body) AGAINST ('engineer' IN BOOLEAN MODE) ORDER BY post_timestamp DESC LIMIT 0,10) as a order by a.a.post_timestamp DESC";

$sql_query_2 = "SELECT title, body, post_timestamp FROM ads_live where country = 'us'";
----------------------------------------------


Hi everyone,

I'm trying to combine an sql query (pasted above) that uses a FULLTEXT index and another that uses standard indexes.

In the first query I'm conducting a fulltex index search of job adverts for the word 'engineer' and ordering by date posted. Then in the second query I'm selecting only adverts posted in the country 'US' using a standard index.

Please could you advise how the two queries can be combined efficiently so that both requirements are met?

Thanks for your help! :-)

Stu


Link to comment
Share on other sites

I'm assuming you're not using the latest version of MySQL, which apparently can use multiple indexes per table.  The "best" way in version 4 is to use the FULLTEXT query as a subquery, and return back the matching UIDs, and then use the PK index for the outer query.
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.