here is a query:
Code: Select all
$qr="EXPLAIN SELECT image_id FROM image WHERE image_galleryId='".$id."' LIMIT 31,60";EXPLAIN output:
id: 1
select_type: SIMPLE
table: image
type: ref
possible_keys: image_galleryId
key: image_galleryId
key_len: 4
ref: const
rows: 504
extra: Using where; Using index
You can see that despite LIMIT clause, db says that it needs to examine
I tried to see what happens as i add more rows to image table(for the same gallery)... i measured execution times by using this basic setup:
Code: Select all
$time_start=microtime();
$res=mysql_query($qr);
$time_end=microtime();
echo($time_end-$time_start);starting from 0.00xxxx sec. for few rows toward 0.1xxxx sec for ~500 rows...(actualy times for more complex query)
Apparently this happens because database kind of "ignores" LIMIT clause... it always scans all the rows
I was execting pretty constant execution time no matter how many rows do i have.
Am I doing something wrong with query?