Search Postgresql Archives

Indexed views like SQL Server - NOT Materialized Views

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



SQL Server has a feature called Indexed Views that are similiar to materialized views.

Basically, the Indexed View supports COUNT/SUM aggregate queries. You create a unique index on the Indexed View and SQL Server automatically keeps the COUNT/SUM upto date.

Example:
CREATE VIEW ForumTopicCounts
AS
SELECT  ForumId, COUNT_BIG(*) AS TopicsCount
FROM Topics
GROUP BY ForumId

CREATE UNIQUE CLUSTERED INDEX idx ON ForumTopicCounts(ForumId);

After doing that, if you add or delete a topic from the Topics Table, SQL Server automatically keeps the count updated.....and it's fast because of the unique index.


Doing the same thing in Postgresql using Materialized views is slow and the developer has to manually issue a "refresh materialized view" command. The alternative is to write additional sql to update count columns....uneccessary work.


Do you know when Postgresql will implement such a feature? Counting is already slow in Postgresql, adding similiar feature like SQL Server will really help.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux