tag:blogger.com,1999:blog-11683713.post111582828619613973..comments2024-01-12T21:16:50.520-08:00Comments on Spyced: Materialized views in PostgreSQLJonathan Ellishttp://www.blogger.com/profile/11003648392946638242noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-11683713.post-45284750215203491422010-02-05T19:18:03.011-08:002010-02-05T19:18:03.011-08:00SQL Server supports materialized views, too. They&...SQL Server supports materialized views, too. They're called "indexed views."Unknownhttps://www.blogger.com/profile/04615074012837414038noreply@blogger.comtag:blogger.com,1999:blog-11683713.post-67516991691622993462008-09-24T10:59:00.000-07:002008-09-24T10:59:00.000-07:00The original link has moved:http://jonathangardner...The original link has moved:<BR/><BR/><A HREF="http://jonathangardner.net/tech/w/PostgreSQL/Materialized_Views" REL="nofollow">http://jonathangardner.net/tech/w/PostgreSQL/Materialized_Views</A>Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-11683713.post-60893908454213566562008-01-23T22:09:00.000-08:002008-01-23T22:09:00.000-08:00Thanks for the pointer, although I don't think lab...Thanks for the pointer, although I don't think labeling someone else's work as Copyright 2008 yourself is kosher, even if his site is gone.Jonathan Ellishttps://www.blogger.com/profile/11003648392946638242noreply@blogger.comtag:blogger.com,1999:blog-11683713.post-15719498689493790172008-01-22T22:44:00.000-08:002008-01-22T22:44:00.000-08:00The original post by Jonathan Gardner is gone. I ...The original post by Jonathan Gardner is gone. I have re-posted it at on my site <A HREF="http://www.benjaminarai.com/benjamin_arai/index.php?display=/postgresql_materialized_views.php" REL="nofollow">Materialized Views in PostgreSQL</A>Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-11683713.post-12947887223410962022007-02-01T12:03:00.000-08:002007-02-01T12:03:00.000-08:00One of the things missing in Postgres from Oracle ...One of the things missing in Postgres from Oracle is the ability to have the select rewritten on the fly to point to a MV table instead of the original table (half of the power of the MV).<br /><br />I hope Postgres SELECT rule restrictions will be loosened in the future to allow for this type of redirection based upon noticing a SELECT is the same as the one that created the MV.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-11683713.post-1135546551930733282005-12-25T13:35:00.000-08:002005-12-25T13:35:00.000-08:00I am merely an interested observer rather than an ...I am merely an interested observer rather than an expert on this subject, but according to a guru of pgsql-general@postgresql.org (Tom Lane) there is no query cache in PG. I would be very interested if somebody could clarify this.<BR/>SWKAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-11683713.post-1115843915642327892005-05-11T13:38:00.000-07:002005-05-11T13:38:00.000-07:00MySQL's query cache works well, but it is a simple...MySQL's query cache works well, but it is a simple solution for simple problems.<BR/><BR/>For Carnage Blender, for instance, the biggest materialized view is stats derived from the main parties table and others. Dozens of queries hit this, joining to different other relations. Using the query cache approach would take far more memory (and memory is an issue for me: I already have a 5 GB database on a 4 GB motherboard) than letting PG cache the relations, with the expensive part precomputed in the mview, and derive what the queries need as necessary.Jonathan Ellishttps://www.blogger.com/profile/11003648392946638242noreply@blogger.comtag:blogger.com,1999:blog-11683713.post-1115842069521224702005-05-11T13:07:00.000-07:002005-05-11T13:07:00.000-07:00Materialized views sound a useful workaround, if y...Materialized views sound a useful workaround, if your database doesn't have a query cache. If you do have a query cache, then you already effectively have eager or lazy materialized views (depending on your isolation level): Just use your normal view (or query) and let the database figure it out.<BR/><BR/>Snapshots are trivial to do in the application, and by definition are refreshed according to application logic (i.e. "only updated when refreshed", according to original article).Anonymoushttps://www.blogger.com/profile/13581204403076051529noreply@blogger.comtag:blogger.com,1999:blog-11683713.post-1115835498893244242005-05-11T11:18:00.000-07:002005-05-11T11:18:00.000-07:00First, it's on a par with the people who say "I ma...First, it's on a par with the people who say "I maintain referential integrity in my application." Sooner or later you or your successor forgets and screws something up. It really isn't if, but when. I've seen this happen at three different companies, unfortunately.<BR/><BR/>Second, it's significantly less efficient to slurp data out of the db, perform computations, and stick it back in, than to do all that inside the database. Often you can wave efficiency under the carpet but presumably you wouldn't be doing this in the first place if you weren't optimizing a bottleneck.<BR/><BR/>Third, it's going to be very tricky to maintain transactional integrity while you perform the updates on the application side. At best you can get by with row locking but often you'll have to use the Big Hammer table lock. With PostgreSQL or Oracle-style MVCC everyone sees a consistent view of the data without locking.<BR/><BR/>Fourth, if you have multiple codebases accessing the data, see #1 and good luck.<BR/><BR/>Finally, maybe you are God's gift to programming and you really can do everything in app logic. And maybe your boss doesn't care about what happens when you leave and he has to hire a mere mortal to maintain it. But if you're happy using lousy tools, why are you using Python instead of C? :)Jonathan Ellishttps://www.blogger.com/profile/11003648392946638242noreply@blogger.comtag:blogger.com,1999:blog-11683713.post-1115834736511688962005-05-11T11:05:00.000-07:002005-05-11T11:05:00.000-07:00Would it be that hard to do in application logic? ...Would it be that hard to do in application logic? Depends somewhat on the database, I guess... but if you can intercept (via application logic) all the updates to that table (or otherwise efficiently detect that they have occurred) then you could manually create the "view" from the application side.Ian Bickinghttps://www.blogger.com/profile/10921115783730718101noreply@blogger.com