NYCPHP Meetup

NYPHP.org

[nycphp-talk] Index files in MySQL

Amir Aavani amir.aavani at gmail.com
Wed Jul 27 03:25:22 EDT 2005


Dear friends
I have some problem in getting query from mysql,
I have table named news in following fornat
ID Int, sid Int, Title Varchar , .... data DateTime
I have a query like this
SELECT count(*) from news where sid in (1, 2, 3, 4, 5 ,6, ...) order
by id LIMIT 0, 10;
I want to force mysql to use id as index (not sid) (because of bug
size of my table) but I was unsuccessfull in that, and always mysql
use filesort to sort the results.
Something wonderfull is when I changed the query to
SELECT count(*) from news where (id< 1000 or id> 100000) order by id
LIMIT 0, 10;
mysql didn't use id as index.

Thanks in advanced
Amir Aavani



More information about the talk mailing list