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 416105295A for ; Wed, 3 Aug 2005 06:23:30 -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 83042-08 for ; Wed, 3 Aug 2005 09:23:15 +0000 (GMT) Received: from mail.gmx.net (pop.gmx.net [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 4C59252904 for ; Wed, 3 Aug 2005 06:23:11 -0300 (ADT) Received: (qmail invoked by alias); 03 Aug 2005 09:23:12 -0000 Received: from p54B9B1E7.dip0.t-ipconnect.de (EHLO merkur.hilbert.loc) [84.185.177.231] by mail.gmx.net (mp022) with SMTP; 03 Aug 2005 11:23:13 +0200 X-Authenticated: #1433807 Received: from ncq by merkur.hilbert.loc with local (Exim 4.50) id 1E0FSu-00010a-D9 for pgsql-sql@postgresql.org; Wed, 03 Aug 2005 11:23:08 +0200 Date: Wed, 3 Aug 2005 11:23:08 +0200 From: Karsten Hilbert To: pgsql-sql@postgresql.org Subject: Re: Trigger on select? Message-ID: <20050803092307.GA2991@merkur.hilbert.loc> References: <42F01AAF.6040903@actarg.com> <42F015E3.8070308@travelamericas.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42F015E3.8070308@travelamericas.com> User-Agent: Mutt/1.5.9i X-Y-GMX-Trusted: 0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.014 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200508/14 X-Sequence-Number: 22242 On Tue, Aug 02, 2005 at 05:54:59PM -0700, Chris Travers wrote: > >Hey, anyone know if it is possible to fire a trigger before a select? > >I'm considering creating some tables which contain data summarized > >from other tables as kind of a cache mechanism. The hope is I can > >speed up some queries that get executed a lot (and are kind of slow) > >by maintaining data (like sums of big columns, for example). I was > >all ready to go and then I discovered that trigger-before-select is > >not supported. (Is it in any DB?) > > > >The idea is this: > > > >Any time I execute a query that would access the summary data, the > >"before select" trigger fires and goes out and builds any summary data > >missing from the summary table. > > No. You must instead generate a view. And then it needs to be a materialized view of some sort to achieve the caching he's after. Karsten -- GPG key ID E4071346 @ wwwkeys.pgp.net E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346