# MySQL server tested (using client version always equal to server version): 4.0.15, 4.0.26, 5.0.45 DROP TABLE IF EXISTS test; CREATE TABLE test ( ID_test varchar(10) binary NOT NULL default '', foo tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (ID_test), KEY foo (foo) ) TYPE=MyISAM PACK_KEYS=1; INSERT INTO test (ID_test, foo) VALUES ('0000000010', 0); INSERT INTO test (ID_test, foo) VALUES ('000000000Z', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001d', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001b', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001e', 0); INSERT INTO test (ID_test, foo) VALUES ('000000000T', 0); INSERT INTO test (ID_test, foo) VALUES ('000000000P', 0); INSERT INTO test (ID_test, foo) VALUES ('0000000019', 0); INSERT INTO test (ID_test, foo) VALUES ('0000000011', 1); INSERT INTO test (ID_test, foo) VALUES ('000000000X', 1); INSERT INTO test (ID_test, foo) VALUES ('000000000c', 0); INSERT INTO test (ID_test, foo) VALUES ('000000000O', 0); INSERT INTO test (ID_test, foo) VALUES ('000000000a', 0); INSERT INTO test (ID_test, foo) VALUES ('000000000k', 0); INSERT INTO test (ID_test, foo) VALUES ('0000000002', 1); INSERT INTO test (ID_test, foo) VALUES ('000000001m', 0); INSERT INTO test (ID_test, foo) VALUES ('0000000007', 0); INSERT INTO test (ID_test, foo) VALUES ('000000000W', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001c', 1); INSERT INTO test (ID_test, foo) VALUES ('0000000009', 0); INSERT INTO test (ID_test, foo) VALUES ('000000000r', 0); INSERT INTO test (ID_test, foo) VALUES ('000000000s', 1); INSERT INTO test (ID_test, foo) VALUES ('0000000017', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001a', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001i', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001g', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001h', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001r', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001p', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001l', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001n', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001o', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001q', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001t', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001s', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001u', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001v', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001w', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001x', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001y', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001A', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001z', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001B', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001G', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001C', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001D', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001E', 1); INSERT INTO test (ID_test, foo) VALUES ('000000001F', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001U', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001H', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001I', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001J', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001K', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001L', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001M', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001N', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001S', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001T', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002b', 1); INSERT INTO test (ID_test, foo) VALUES ('0000000022', 0); INSERT INTO test (ID_test, foo) VALUES ('0000000021', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001V', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001W', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001X', 0); INSERT INTO test (ID_test, foo) VALUES ('000000001Y', 0); INSERT INTO test (ID_test, foo) VALUES ('0000000025', 0); INSERT INTO test (ID_test, foo) VALUES ('0000000026', 0); INSERT INTO test (ID_test, foo) VALUES ('0000000027', 0); INSERT INTO test (ID_test, foo) VALUES ('0000000028', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002d', 1); INSERT INTO test (ID_test, foo) VALUES ('0000000029', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002a', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002g', 1); INSERT INTO test (ID_test, foo) VALUES ('000000002c', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002k', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002e', 1); INSERT INTO test (ID_test, foo) VALUES ('000000002h', 1); INSERT INTO test (ID_test, foo) VALUES ('000000002j', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002l', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002m', 1); INSERT INTO test (ID_test, foo) VALUES ('000000002q', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002p', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002x', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002r', 1); INSERT INTO test (ID_test, foo) VALUES ('000000002u', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002v', 1); INSERT INTO test (ID_test, foo) VALUES ('000000002w', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002z', 0); INSERT INTO test (ID_test, foo) VALUES ('000000002y', 1); # Output order is (not surprisingly) same of inserts mysql> SELECT * FROM test; +------------+-----+ | ID_test | foo | +------------+-----+ | 0000000010 | 0 | | 000000000Z | 0 | | 000000001d | 0 | | 000000001b | 0 | | 000000001e | 0 | | 000000000T | 0 | | 000000000P | 0 | | 0000000019 | 0 | | 0000000011 | 1 | | 000000000X | 1 | | 000000000c | 0 | | 000000000O | 0 | | 000000000a | 0 | | 000000000k | 0 | | 0000000002 | 1 | | 000000001m | 0 | | 0000000007 | 0 | | 000000000W | 0 | | 000000001c | 1 | | 0000000009 | 0 | | 000000000r | 0 | | 000000000s | 1 | | 0000000017 | 0 | | 000000001a | 0 | | 000000001i | 0 | | 000000001g | 0 | | 000000001h | 0 | | 000000001r | 0 | | 000000001p | 0 | | 000000001l | 0 | | 000000001n | 0 | | 000000001o | 0 | | 000000001q | 0 | | 000000001t | 0 | | 000000001s | 0 | | 000000001u | 0 | | 000000001v | 0 | | 000000001w | 0 | | 000000001x | 0 | | 000000001y | 0 | | 000000001A | 0 | | 000000001z | 0 | | 000000001B | 0 | | 000000001G | 0 | | 000000001C | 0 | | 000000001D | 0 | | 000000001E | 1 | | 000000001F | 0 | | 000000001U | 0 | | 000000001H | 0 | | 000000001I | 0 | | 000000001J | 0 | | 000000001K | 0 | | 000000001L | 0 | | 000000001M | 0 | | 000000001N | 0 | | 000000001S | 0 | | 000000001T | 0 | | 000000002b | 1 | | 0000000022 | 0 | | 0000000021 | 0 | | 000000001V | 0 | | 000000001W | 0 | | 000000001X | 0 | | 000000001Y | 0 | | 0000000025 | 0 | | 0000000026 | 0 | | 0000000027 | 0 | | 0000000028 | 0 | | 000000002d | 1 | | 0000000029 | 0 | | 000000002a | 0 | | 000000002g | 1 | | 000000002c | 0 | | 000000002k | 0 | | 000000002e | 1 | | 000000002h | 1 | | 000000002j | 0 | | 000000002l | 0 | | 000000002m | 1 | | 000000002q | 0 | | 000000002p | 0 | | 000000002x | 0 | | 000000002r | 1 | | 000000002u | 0 | | 000000002v | 1 | | 000000002w | 0 | | 000000002z | 0 | | 000000002y | 1 | +------------+-----+ 89 rows in set (0.01 sec) mysql> SELECT * FROM test ORDER BY foo DESC LIMIT 0, 15; +------------+-----+ | ID_test | foo | +------------+-----+ | 000000002y | 1 | | 000000002v | 1 | | 000000002r | 1 | | 000000002m | 1 | | 000000002h | 1 | | 000000002e | 1 | | 000000002g | 1 | | 000000002d | 1 | | 000000002b | 1 | | 000000001E | 1 | | 000000000s | 1 | | 000000001c | 1 | | 0000000002 | 1 | | 000000000X | 1 | | 0000000011 | 1 | +------------+-----+ 15 rows in set (0.00 sec) mysql> SELECT * FROM test ORDER BY foo DESC LIMIT 15, 15; +------------+-----+ | ID_test | foo | +------------+-----+ | 000000002z | 0 | | 000000002w | 0 | | 000000002u | 0 | | 000000002x | 0 | | 000000002p | 0 | | 000000002q | 0 | | 000000002l | 0 | | 000000002j | 0 | | 000000002k | 0 | | 000000002c | 0 | | 000000002a | 0 | | 0000000029 | 0 | | 0000000028 | 0 | | 0000000027 | 0 | | 0000000026 | 0 | +------------+-----+ 15 rows in set (0.00 sec) mysql> SELECT * FROM test ORDER BY foo DESC LIMIT 30, 15; +------------+-----+ | ID_test | foo | +------------+-----+ | 0000000025 | 0 | | 000000001Y | 0 | | 000000001X | 0 | | 000000001W | 0 | | 000000001V | 0 | | 0000000021 | 0 | | 0000000022 | 0 | | 000000001T | 0 | | 000000001S | 0 | | 000000001N | 0 | | 000000001M | 0 | | 000000001L | 0 | | 000000001K | 0 | | 000000001J | 0 | | 000000001I | 0 | +------------+-----+ 15 rows in set (0.00 sec) mysql> SELECT * FROM test ORDER BY foo DESC LIMIT 45, 15; +------------+-----+ | ID_test | foo | +------------+-----+ | 000000001H | 0 | | 000000001U | 0 | | 000000001F | 0 | | 000000001D | 0 | | 000000001C | 0 | | 000000001G | 0 | | 000000001B | 0 | | 000000001z | 0 | | 000000001A | 0 | | 000000001y | 0 | | 000000001x | 0 | | 000000001w | 0 | | 000000001v | 0 | | 000000001u | 0 | | 000000001s | 0 | +------------+-----+ 15 rows in set (0.00 sec) mysql> SELECT * FROM test ORDER BY foo DESC LIMIT 60, 15; +------------+-----+ | ID_test | foo | +------------+-----+ | 000000001t | 0 | | 000000001q | 0 | | 000000001o | 0 | | 000000001n | 0 | | 000000001l | 0 | | 000000001p | 0 | | 000000001r | 0 | | 000000001h | 0 | | 000000001g | 0 | | 000000001i | 0 | | 000000001a | 0 | | 0000000017 | 0 | | 000000000r | 0 | | 0000000009 | 0 | | 000000000W | 0 | +------------+-----+ 15 rows in set (0.00 sec) # ATTENTION NEEDED!!! # Unexpected and different outputs begin here! # 4.0.15 and 4.0.26 have same output, while 5.0.45 differs from earlier # All "LIMIT 75, 15" queries seem to be wrong to me! # ATTENTION NEEDED!!! # You can find same ID_test looking at "LIMIT 15, 15" (reverse order, skippin last) mysq[4.0.15, 4.0.26]> SELECT * FROM test ORDER BY foo DESC LIMIT 75, 15; +------------+-----+ | ID_test | foo | +------------+-----+ | 0000000027 | 0 | | 0000000028 | 0 | | 0000000029 | 0 | | 000000002a | 0 | | 000000002c | 0 | | 000000002k | 0 | | 000000002j | 0 | | 000000002l | 0 | | 000000002q | 0 | | 000000002p | 0 | | 000000002x | 0 | | 000000002u | 0 | | 000000002w | 0 | | 000000002z | 0 | +------------+-----+ 14 rows in set (0.00 sec) # Compared with "no limit" query on same server version, in previuos query I got the last 14 lines mysq[4.0.15, 4.0.26]> SELECT * FROM test ORDER BY foo DESC; +------------+-----+ | ID_test | foo | +------------+-----+ | 0000000011 | 1 | | 000000000X | 1 | | 0000000002 | 1 | | 000000001c | 1 | | 000000000s | 1 | | 000000001E | 1 | | 000000002b | 1 | | 000000002d | 1 | | 000000002g | 1 | | 000000002e | 1 | | 000000002h | 1 | | 000000002m | 1 | | 000000002r | 1 | | 000000002v | 1 | | 000000002y | 1 | | 0000000010 | 0 | | 000000000Z | 0 | | 000000001d | 0 | | 000000001b | 0 | | 000000001e | 0 | | 000000000T | 0 | | 000000000P | 0 | | 0000000019 | 0 | | 000000000c | 0 | | 000000000O | 0 | | 000000000a | 0 | | 000000000k | 0 | | 000000001m | 0 | | 0000000007 | 0 | | 000000000W | 0 | | 0000000009 | 0 | | 000000000r | 0 | | 0000000017 | 0 | | 000000001a | 0 | | 000000001i | 0 | | 000000001g | 0 | | 000000001h | 0 | | 000000001r | 0 | | 000000001p | 0 | | 000000001l | 0 | | 000000001n | 0 | | 000000001o | 0 | | 000000001q | 0 | | 000000001t | 0 | | 000000001s | 0 | | 000000001u | 0 | | 000000001v | 0 | | 000000001w | 0 | | 000000001x | 0 | | 000000001y | 0 | | 000000001A | 0 | | 000000001z | 0 | | 000000001B | 0 | | 000000001G | 0 | | 000000001C | 0 | | 000000001D | 0 | | 000000001F | 0 | | 000000001U | 0 | | 000000001H | 0 | | 000000001I | 0 | | 000000001J | 0 | | 000000001K | 0 | | 000000001L | 0 | | 000000001M | 0 | | 000000001N | 0 | | 000000001S | 0 | | 000000001T | 0 | | 0000000022 | 0 | | 0000000021 | 0 | | 000000001V | 0 | | 000000001W | 0 | | 000000001X | 0 | | 000000001Y | 0 | | 0000000025 | 0 | | 0000000026 | 0 | | 0000000027 | 0 | | 0000000028 | 0 | | 0000000029 | 0 | | 000000002a | 0 | | 000000002c | 0 | | 000000002k | 0 | | 000000002j | 0 | | 000000002l | 0 | | 000000002q | 0 | | 000000002p | 0 | | 000000002x | 0 | | 000000002u | 0 | | 000000002w | 0 | | 000000002z | 0 | +------------+-----+ 89 rows in set (0.00 sec) # You can find same ID_test looking at "LIMIT 45, 15" and "LIMIT 60, 15" (sparse order) mysql[5.0.45]> SELECT * FROM test ORDER BY foo DESC LIMIT 75, 15; +------------+-----+ | ID_test | foo | +------------+-----+ | 000000001B | 0 | | 000000001G | 0 | | 000000001C | 0 | | 000000001v | 0 | | 000000001u | 0 | | 000000001r | 0 | | 000000001p | 0 | | 000000001l | 0 | | 000000001n | 0 | | 000000001o | 0 | | 000000001q | 0 | | 000000001t | 0 | | 000000001s | 0 | | 000000001D | 0 | +------------+-----+ 14 rows in set (0.00 sec) # Compared with "no limit" query on same server version, in previuos query I got the last 14 lines mysq[5.0.45]> SELECT * FROM test ORDER BY foo DESC; +------------+-----+ | ID_test | foo | +------------+-----+ | 000000002r | 1 | | 000000002h | 1 | | 000000002e | 1 | | 000000001c | 1 | | 000000001E | 1 | | 000000002g | 1 | | 000000000s | 1 | | 000000002b | 1 | | 000000002d | 1 | | 000000002y | 1 | | 0000000002 | 1 | | 000000002m | 1 | | 000000002v | 1 | | 000000000X | 1 | | 0000000011 | 1 | | 0000000022 | 0 | | 000000001U | 0 | | 0000000021 | 0 | | 000000001V | 0 | | 000000001T | 0 | | 000000001W | 0 | | 000000001M | 0 | | 000000001H | 0 | | 000000001I | 0 | | 000000001J | 0 | | 000000001K | 0 | | 000000001S | 0 | | 000000001L | 0 | | 000000001N | 0 | | 000000001X | 0 | | 000000001Y | 0 | | 000000002w | 0 | | 000000002u | 0 | | 0000000026 | 0 | | 000000002x | 0 | | 000000002p | 0 | | 000000002q | 0 | | 000000002l | 0 | | 000000002j | 0 | | 000000002k | 0 | | 000000002c | 0 | | 000000002a | 0 | | 0000000029 | 0 | | 0000000028 | 0 | | 0000000027 | 0 | | 0000000025 | 0 | | 000000002z | 0 | | 000000001F | 0 | | 0000000010 | 0 | | 000000000k | 0 | | 000000001m | 0 | | 0000000007 | 0 | | 000000000W | 0 | | 0000000009 | 0 | | 000000000r | 0 | | 0000000017 | 0 | | 000000001a | 0 | | 000000000a | 0 | | 000000000O | 0 | | 000000000Z | 0 | | 000000001d | 0 | | 000000001b | 0 | | 000000001e | 0 | | 000000000T | 0 | | 000000000P | 0 | | 0000000019 | 0 | | 000000000c | 0 | | 000000001i | 0 | | 000000001g | 0 | | 000000001h | 0 | | 000000001w | 0 | | 000000001x | 0 | | 000000001y | 0 | | 000000001A | 0 | | 000000001z | 0 | | 000000001B | 0 | | 000000001G | 0 | | 000000001C | 0 | | 000000001v | 0 | | 000000001u | 0 | | 000000001r | 0 | | 000000001p | 0 | | 000000001l | 0 | | 000000001n | 0 | | 000000001o | 0 | | 000000001q | 0 | | 000000001t | 0 | | 000000001s | 0 | | 000000001D | 0 | +------------+-----+ 89 rows in set (0.00 sec) # In previuos outputs, on any server version, I never got the following records # They are first 14 inserted records with foo=0 # Just notice that ID_test 0000000011, 000000000X, 0000000002 with foo=1 have been outputted on query "LIMIT 0, 15" # EXPECTED and simulated output: +------------+-----+ | ID_test | foo | +------------+-----+ | 0000000010 | 0 | | 000000000Z | 0 | | 000000001d | 0 | | 000000001b | 0 | | 000000001e | 0 | | 000000000T | 0 | | 000000000P | 0 | | 0000000019 | 0 | | 000000000c | 0 | | 000000000O | 0 | | 000000000a | 0 | | 000000000k | 0 | | 000000001m | 0 | | 0000000007 | 0 | +------------+-----+