Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 00A4F6325F4 for ; Fri, 15 Jan 2010 12:05:26 -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 53238-06 for ; Fri, 15 Jan 2010 16:05:15 +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 4963263225A for ; Fri, 15 Jan 2010 12:05:15 -0400 (AST) Received: from list by lo.gmane.org with local (Exim 4.50) id 1NVofg-00053l-N5 for pgsql-sql@postgresql.org; Fri, 15 Jan 2010 17:05:12 +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 ; Fri, 15 Jan 2010 17:05:12 +0100 Received: from spluque by s01060015e975d7fb.wp.shawcable.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 15 Jan 2010 17:05:12 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Seb Subject: indexes Date: Fri, 15 Jan 2010 10:04:56 -0600 Organization: Church of Emacs Lines: 19 Message-ID: <87iqb3z74n.fsf@kolob.sebmags.homelinux.org> 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:zHOjHtUMua02ih5O4xuPbFlwFLY= 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/29 X-Sequence-Number: 33565 Hi, I have some views and queries that take a bit too long to return, so perhaps some judicious indexes might help, but I don't know much about how to use them. The PostgreSQL manual has a good section on indexes, but I can't find guidance on (unless I missed something): o How to decide what columns need an index? o Should all foreign keys have an index? o Naming conventions? o Does PostgreSQL use available indexes that can be useful in any query, without the user having to do anything in particular? I'd appreciate any pointers to documents with guidance on these questions. Thanks. -- Seb