Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 268306333B8 for ; Fri, 10 Sep 2010 23:03:46 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 40131-01 for ; Sat, 11 Sep 2010 02:03:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tamriel.snowman.net (tamriel.snowman.net [72.66.115.51]) by mail.postgresql.org (Postfix) with ESMTP id 0C1EB633399 for ; Fri, 10 Sep 2010 23:03:39 -0300 (ADT) Received: by tamriel.snowman.net (Postfix, from userid 1000) id 917A222260; Fri, 10 Sep 2010 22:03:37 -0400 (EDT) Date: Fri, 10 Sep 2010 22:03:37 -0400 From: Stephen Frost To: Tom Lane Cc: Mason Harding , pgsql-performance@postgresql.org Subject: Re: Slow SQL lookup due to every field being listed in SORT KEY Message-ID: <20100911020337.GH26232@tamriel.snowman.net> References: <5323.1284170438@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+FXO89QiasSPfgz+" Content-Disposition: inline In-Reply-To: <5323.1284170438@sss.pgh.pa.us> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/2.6.26-1-amd64 (x86_64) X-Uptime: 22:02:04 up 379 days, 13:27, 16 users, load average: 0.04, 0.05, 0.02 User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201009/50 X-Sequence-Number: 40253 --+FXO89QiasSPfgz+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline * Tom Lane (tgl@sss.pgh.pa.us) wrote: > The reason it's sorting by all the columns is the DISTINCT You might also verify that you actually need/*should* have the DISTINCT, if it's included today.. Often developers put that in without understanding why they're getting dups (which can often be due to missing pieces from the JOIN clause or misunderstanding of the database schema...). Stephen --+FXO89QiasSPfgz+ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkyK43kACgkQrzgMPqB3kihX4ACfVboO4jRzFO3hkckdHfrSeAgF sysAnjmeoV7BA7uClEY8gXT4nEYhSx0u =y556 -----END PGP SIGNATURE----- --+FXO89QiasSPfgz+--