Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 70F3E9FB252 for ; Fri, 3 Nov 2006 15:36:11 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 59466-03 for ; Fri, 3 Nov 2006 15:36:07 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id B0BDC9FB1FE for ; Fri, 3 Nov 2006 15:36:06 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1Gg4pl-0003Rm-FD for pgsql-sql@postgresql.org; Fri, 03 Nov 2006 14:36:09 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 33C1B41A2; Fri, 3 Nov 2006 14:36:00 -0500 (EST) Date: Fri, 3 Nov 2006 14:36:00 -0500 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Index + View Question Message-ID: <20061103193600.GB32617@phlogiston.dyndns.org> References: <3ddac38d0611031117v742c5c84p3264c894709b559d@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3ddac38d0611031117v742c5c84p3264c894709b559d@mail.gmail.com> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/44 X-Sequence-Number: 26696 On Fri, Nov 03, 2006 at 11:17:30AM -0800, Dylan Lorimer wrote: > If I've got several tables, each with their own indexes. I also have a view > that aggregates several of these tables. My question is, as novice-like as > it may sound, do I need to create new indexes on the view or do the indexes > from the orig. tables apply somehow when I select data from the view? You _can't_ create an index on the view. Depending on what version of PostgreSQL you are using, it will be more or less intelligent about using the indexes in your views. But keep in mind that there are some cases where the indexes on several tables simply won't work -- if the condition is such that all the tables need to be compared to one another, for instant, no index will help you, because you'll end up pulling everything into memory before anything else can happen. A -- Andrew Sullivan | ajs@crankycanuck.ca When my information changes, I alter my conclusions. What do you do sir? --attr. John Maynard Keynes