`replaceCountStar` should also replace count(primary key) and unique indexes with only non-nullable columns
max-hoffman opened this issue · comments
Maximilian Hoffman commented
I think the count of a primary key and count of a unique index with all non-nullable columns should both equivalent to count(*)
:
create table xyz (x int primary key, y int not null, z int, unique index (y), unique index (z));
select count(x) from xyz; -- plan.TableCount() lookup
select count(y) from xyz; -- plan.TableCount() lookup
select count(z) from xyz; -- NULL values might make this count lower
Maximilian Hoffman commented
Partially implemented here dolthub/go-mysql-server#2494. We do not implement for unique non-null keys yet.