I've got a table with a bunch of statistics from counties in the US.
Because it's so large, I want to index it with a comprehensive set of partial indexes.
CREATE INDEX county_stats_34_idx on stats_county (stateid, countyid, site, yeargroup, foo, bar)
WHERE stateid = 1;
CREATE INDEX county_stats_25_idx on stats_county (stateid, countyid, site, yeargroup, foo, bar)
WHERE stateid = 2;
...
CREATE INDEX county_stats_32_idx on stats_county (stateid, countyid, site, yeargroup, foo, bar)
WHERE stateid = 53;
This is going to scan each row of the table 53 times, checking stateid and adding to the index where appropriate. I wonder--is there a more efficient way to create these indices? Logically, it only needs to scan the table once, with a 53-item switch...
Just curious, since it seems like I'll be needing to do this sort of thing with some frequency...
Thanks!