Index for count and group by


Are there anyway to improve performance of group by condition:
SELECT source, count(*) FROM default
GROUP BY source
I tried to create create index on “source” but didnot help


If count on MISSING source is not required. Try this.

CREATE INDEX ix1 ON default(source);
SELECT source, count(1) FROM default  WHERE source IS NOT MISSING GROUP BY source;

Also check article by @keshav_m

1 Like