X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6A1FA52952 for ; Mon, 28 Mar 2005 23:04:30 +0100 (BST) 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 95281-09 for ; Mon, 28 Mar 2005 22:04:21 +0000 (GMT) Received: from koolancexeon.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by svr1.postgresql.org (Postfix) with ESMTP id 857885320B for ; Mon, 28 Mar 2005 23:04:21 +0100 (BST) Received: mail.g2switchworks.com 10.10.1.8 from 10.10.1.37 10.10.1.37 via HTTP with MS-WebStorage 6.5.6944 Received: from state.g2switchworks.com by mail.g2switchworks.com; 28 Mar 2005 16:04:23 -0600 Subject: Re: cost of CREATE VIEW ... AS SELECT DISTINCT From: Scott Marlowe To: mailreg@numerixtechnology.de Cc: pgsql-sql@postgresql.org In-Reply-To: <42487A6D.6020506@numerixtechnology.de> References: <42487A6D.6020506@numerixtechnology.de> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1112047463.22988.25.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Mon, 28 Mar 2005 16:04:23 -0600 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/370 X-Sequence-Number: 20849 On Mon, 2005-03-28 at 15:43, T E Schmitz wrote: > Hello, > How expensive would it be to maintain the following VIEW: > > CREATE VIEW origin AS SELECT DISTINCT origin FROM transaktion > > if there is in index on transaktion.origin; the table transaktion has > thousands of records and there are only a few distinct origin? The cost will only be encurred when running the view. if you want materialized views (which WOULD have maintenance costs) you'll have to do a google search for postgresql materialized views and implement them by hand, so to speak. The cost of executing that view should be the same as the cost of running the query by hand.