Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id A5B656327B4 for ; Sun, 17 Jan 2010 21:10:52 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 67155-04-3 for ; Mon, 18 Jan 2010 01:10:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 2BDF563424C for ; Sun, 17 Jan 2010 21:10:33 -0400 (AST) Received: from list by lo.gmane.org with local (Exim 4.50) id 1NWg8T-0001Pz-F8 for pgsql-sql@postgresql.org; Mon, 18 Jan 2010 02:10:29 +0100 Received: from s01060015e975d7fb.wp.shawcable.net ([24.77.73.195]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 18 Jan 2010 02:10:29 +0100 Received: from spluque by s01060015e975d7fb.wp.shawcable.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 18 Jan 2010 02:10:29 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Seb Subject: Re: indexes Date: Sun, 17 Jan 2010 19:10:08 -0600 Organization: Church of Emacs Lines: 24 Message-ID: <87fx64jk0f.fsf@kolob.sebmags.homelinux.org> References: <87iqb3z74n.fsf@kolob.sebmags.homelinux.org> <4B53885C.3060706@gmail.com> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: s01060015e975d7fb.wp.shawcable.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:Og3J9Ga+ULfGGbYLPh9/3qYCie0= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201001/32 X-Sequence-Number: 33568 On Mon, 18 Jan 2010 08:59:56 +1100, Chris wrote: >> o Should all foreign keys have an index? > Not necessarily, you might just want the db to enforce the restriction > but not actually use the data in it. For example, keep a userid (and > timestamp) column of the last person to update a row. You may need it > to say "aha - this was last changed on this date and by person X", but > you'll never generally use it. > If you never have a where clause with that column, no need to index > it. If you're using it in a join all the time, then yes it would be > better to index it. Thanks for all your pointers! Do views use the indexes in the underlying tables, whenever say a SELECT operation is called on the view? If so, indexes on views don't make any sense right? -- Seb