I was able to reproduce this behavior:
drizzle> create table dis ( -> a int not null, -> b int not null, -> c int not null, -> d int not null, -> key foo (c, d, a, b), -> key bar (c, a, b, d) -> ) engine=InnoDB; Query OK, 0 rows affected (0.01 sec)
drizzle> insert into dis values -> (0,0,0,3), -> (0,0,0,4), -> (0,0,0,4), -> (0,0,0,5), -> (0,0,1,0), -> (0,0,1,0), -> (0,0,1,1), -> (0,0,1,1), -> (0,0,1,2), -> (0,0,1,3), -> (0,0,1,4), -> (0,0,1,5), -> (0,0,2,1), -> (0,0,2,2), -> (0,0,2,2), -> (0,0,2,3), -> (0,0,2,3), -> (0,0,2,4), -> (0,0,2,4), -> (0,0,3,0), -> (0,0,3,0), -> (0,0,3,1), -> (0,0,3,1), -> (0,0,3,1), -> (0,0,3,1), -> (0,0,3,3), -> (0,0,3,3), -> (0,0,3,3), -> (0,0,3,4), -> (0,0,3,4), -> (0,0,3,4), -> (0,0,3,4), -> (0,0,3,4), -> (0,0,3,5), -> (0,0,4,0), -> (0,0,4,0), -> (0,0,4,0), -> (0,0,4,1), -> (0,0,4,1), -> (0,0,4,3), -> (0,0,4,3), -> (0,0,4,3), -> (0,0,4,3), -> (0,0,4,3), -> (0,0,4,4), -> (0,0,4,4), -> (0,0,5,0), -> (0,0,5,0), -> (0,0,5,1), -> (0,0,5,3); Query OK, 50 rows affected (0.01 sec) Records: 50 Duplicates: 0 Warnings: 0
drizzle> analyze table dis; +----------+---------+----------+----------+ | Table | Op | Msg_type | Msg_text | +----------+---------+----------+----------+ | test.dis | analyze | status | OK | +----------+---------+----------+----------+ 1 row in set (0.00 sec)
drizzle> select c from dis where d = 4; +---+ | c | +---+ | 0 | | 0 | | 1 | | 2 | | 2 | | 3 | | 3 | | 3 | | 3 | | 3 | | 4 | | 4 | +---+ 12 rows in set (0.00 sec)
drizzle> select distinct c from dis where d = 4; Empty set (0.00 sec)
drizzle> select distinct c from dis where d = 4 order by a; +---+ | c | +---+ | 0 | | 1 | | 2 | | 3 | | 4 | +---+ 5 rows in set (0.00 sec)
drizzle>
Thanks, Padraig.
I was able to reproduce this behavior:
drizzle> create table dis (
-> a int not null,
-> b int not null,
-> c int not null,
-> d int not null,
-> key foo (c, d, a, b),
-> key bar (c, a, b, d)
-> ) engine=InnoDB;
Query OK, 0 rows affected (0.01 sec)
drizzle> insert into dis values
-> (0,0,0,3),
-> (0,0,0,4),
-> (0,0,0,4),
-> (0,0,0,5),
-> (0,0,1,0),
-> (0,0,1,0),
-> (0,0,1,1),
-> (0,0,1,1),
-> (0,0,1,2),
-> (0,0,1,3),
-> (0,0,1,4),
-> (0,0,1,5),
-> (0,0,2,1),
-> (0,0,2,2),
-> (0,0,2,2),
-> (0,0,2,3),
-> (0,0,2,3),
-> (0,0,2,4),
-> (0,0,2,4),
-> (0,0,3,0),
-> (0,0,3,0),
-> (0,0,3,1),
-> (0,0,3,1),
-> (0,0,3,1),
-> (0,0,3,1),
-> (0,0,3,3),
-> (0,0,3,3),
-> (0,0,3,3),
-> (0,0,3,4),
-> (0,0,3,4),
-> (0,0,3,4),
-> (0,0,3,4),
-> (0,0,3,4),
-> (0,0,3,5),
-> (0,0,4,0),
-> (0,0,4,0),
-> (0,0,4,0),
-> (0,0,4,1),
-> (0,0,4,1),
-> (0,0,4,3),
-> (0,0,4,3),
-> (0,0,4,3),
-> (0,0,4,3),
-> (0,0,4,3),
-> (0,0,4,4),
-> (0,0,4,4),
-> (0,0,5,0),
-> (0,0,5,0),
-> (0,0,5,1),
-> (0,0,5,3);
Query OK, 50 rows affected (0.01 sec)
Records: 50 Duplicates: 0 Warnings: 0
drizzle> analyze table dis; ----+-- ------- +------ ----+-- ------- -+ ----+-- ------- +------ ----+-- ------- -+ ----+-- ------- +------ ----+-- ------- -+
+------
| Table | Op | Msg_type | Msg_text |
+------
| test.dis | analyze | status | OK |
+------
1 row in set (0.00 sec)
drizzle> select c from dis where d = 4;
+---+
| c |
+---+
| 0 |
| 0 |
| 1 |
| 2 |
| 2 |
| 3 |
| 3 |
| 3 |
| 3 |
| 3 |
| 4 |
| 4 |
+---+
12 rows in set (0.00 sec)
drizzle> select distinct c from dis where d = 4;
Empty set (0.00 sec)
drizzle> select distinct c from dis where d = 4 order by a;
+---+
| c |
+---+
| 0 |
| 1 |
| 2 |
| 3 |
| 4 |
+---+
5 rows in set (0.00 sec)
drizzle>
Thanks, Padraig.