2 ms·
Looking at the documentation, MySQL definitely has this feature now. I don't think it understands when to use it. I have a table where the primary key (A,B) i
by Dylan16807 1y ago
Looking at the documentation, MySQL definitely has this feature now.
I don't think it understands when to use it.
I have a table where the primary key (A,B) is two integers. The first one is a single byte and only has a dozen distinct values. Any query I do based on just B ends up doing a table scan and being extremely slow. But if I add "WHERE A IN (1,2,3,4,5,6,7,8,9,10,11) AND" suddenly it's super fast.
So I'm stuck with a redundant index on just B if I don't want to add that cruft all over.
Anyway, yes, optimization is often possible in this kind of situation but don't trust your database engine to figure it out.