X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 857F052881 for ; Tue, 21 Jun 2005 11:49:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18800-09 for ; Tue, 21 Jun 2005 14:49:29 +0000 (GMT) Received: from mail-relay1.tagaudit.com (unknown [69.64.214.4]) by svr1.postgresql.org (Postfix) with ESMTP id D10385283A for ; Tue, 21 Jun 2005 11:49:25 -0300 (ADT) Received: from mail-hub.tagaudit.com (dns2.tagaudit.com [192.168.3.32]) by mail-relay1.tagaudit.com (Postfix) with ESMTP id F39DA200000B8 for ; Tue, 21 Jun 2005 10:49:30 -0400 (EDT) Received: by mail-hub.tagaudit.com (Postfix, from userid 8) id E5A6022009; Tue, 21 Jun 2005 10:49:30 -0400 (EDT) Received: from xeon400.tagaudit.com (xeon400.tagaudit.com [192.168.3.17]) by mail-hub.tagaudit.com (Postfix) with ESMTP id C4CAB11362; Tue, 21 Jun 2005 10:49:30 -0400 (EDT) Received: by vpn.tagaudit.com with Internet Mail Service (5.5.2656.59) id ; Tue, 21 Jun 2005 10:49:30 -0400 Message-ID: <0C072E7CC947D511AC9600A0CC7341200256CF52@vpn.tagaudit.com> From: Amit V Shah To: "'newz@bearfruit.org'" Cc: pgsql-performance@postgresql.org Subject: Re: Do Views execute underlying query everytime ?? Date: Tue, 21 Jun 2005 10:49:28 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.35 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200506/381 X-Sequence-Number: 13018 After I sent out this email, I found this article from google http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html Looks like we can control as to when the views refresh... I am still kind of confused, and would appreciate help !! The create/drop table does sound a solution that can work, but the thing is I want to get manual intervention out, and besides, my work flow is very complex so this might not be an option for me :-( Thanks, Amit -----Original Message----- From: Matthew Nuzum [mailto:mattnuzum@gmail.com] Sent: Tuesday, June 21, 2005 10:45 AM To: Amit V Shah Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Do Views execute underlying query everytime ?? On 6/21/05, Amit V Shah wrote: > Hi all, ... > I am thinking of having a solution where I create views for each screen, > which are just read only. > > However, I donot know if the query that creates the view is executed > everytime I select something from the view. Because if that is the case, > then I think my queries will again be slow. But if that is the way views > work, then what would be the point in creating them .. > > Any suggestions, helps -- They do get executed every time. I have a similar issue, but my data does not change very frequently, so instead of using a view, I create lookup tables to hold the data. So once a day I do something like this: drop lookup_table_1; create table lookup_table_1 as SELECT ...; In my case, rows are not deleted or updated, so I don't actually do a "drop table..." I merely add new records to the existing table, but if your data changes, the drop table technique can be faster than doing a delete or update. -- Matthew Nuzum www.bearfruit.org