Assume this general SQL query takes too long to execute. Which of the 4 options below can be done to improve its performance? Why? This is just for the understanding of SQL, not a dbms specific.
CREATE INDEX IDX ON Vaccinations (COUNT(*), Site)
Wrap the query in a view and ask users to query from the view.
CREATE AGGREGATE INDEX ON Vaccinations(COUNT(*))
CREATE INDEX IDX ON Vaccinations (Site)
SELECT Site, COUNT(*) AS Number of Vaccinations
FROM Vaccinations
GROUP BY Site;
A few rows from the Vaccinations
table is shown here:
Personally, I'm leaning towards 1. Since the count(*)
is the only thing being used in the SELECT...FROM
as a condition. However, I'm not entirely sure what the "aggregate index" option entails. Can someone explain when it's preferred over normal index? Thanks!