edit: i've discovered problem appears when use phpmyadmin execute query, , not when execute same query using php's mysql_query(). (my webhost not provide command-line access.) specifically, when run on table of 65k+ rows, phpmyadmin appears hang, mysql_query() returns expected result. i have table: products (product_id, shop_id, date) for each shop_id in table, following query retrieves 10 rows recent dates set @num := 0, @shop_id := null; select shop_id, date ( select shop_id, date, @num := if(@shop_id = shop_id, @num + 1, 1) row_number, @shop_id := shop_id dummy products order shop_id, date desc ) x x.row_number <= 10; for example, if there 10 distinct shop_ids, , each of these shop_ids appears in @ least 10 rows, query return 100 rows, 10 per shop_id. query works fine. in addition date , shop_id, select product_id each row. while following query works fine abut 55k rows, when try 65k rows, mysql appears hang indefinitely (at least php...