Query - Optimized
Posted: Thu Apr 14, 2011 12:06 pm
Hi,
I have two table involved in this query.
One is questions (now have 20,000 records - It might grow to 1 lakh in future)
Another one is user who attended questions.
Now, I want to get only unattended random questions.
first, I get the maximum id from questions table. then,
After that, I write
The Not IN part might take more and more ids in future.
>=$rand have chance to bring no result, i think
Please give me some idea to optimize this query if i am wrong.
I have two table involved in this query.
One is questions (now have 20,000 records - It might grow to 1 lakh in future)
Another one is user who attended questions.
Now, I want to get only unattended random questions.
first, I get the maximum id from questions table. then,
Code: Select all
$rand = rand(1,$max_id);Code: Select all
select * from questions where id not in (subsquery) and id >= $rand>=$rand have chance to bring no result, i think
Please give me some idea to optimize this query if i am wrong.