X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0841D52848 for ; Mon, 11 Jul 2005 22:48:58 -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 97422-07 for ; Tue, 12 Jul 2005 01:48:49 +0000 (GMT) Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) by svr1.postgresql.org (Postfix) with ESMTP id E9ED8529A9 for ; Mon, 11 Jul 2005 22:48:47 -0300 (ADT) Received: from juju.arbash-meinel.com ([12.214.18.81]) by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP id <20050712014852m920060ddae>; Tue, 12 Jul 2005 01:48:52 +0000 Received: by juju.arbash-meinel.com (Postfix, from userid 505) id A86C255FEC; Mon, 11 Jul 2005 20:48:51 -0500 (CDT) Received: from [192.168.1.102] (209-181-211-15.cdrr.qwest.net [209.181.211.15]) by juju.arbash-meinel.com (Postfix) with ESMTP id D9C0755F98; Mon, 11 Jul 2005 20:48:46 -0500 (CDT) Message-ID: <42D3217C.20703@arbash-meinel.com> Date: Mon, 11 Jul 2005 20:48:44 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Chris Travers , Postgresql Performance Subject: Re: Sorting on longer key is faster ? References: <20050709183842.2EABF52820@svr1.postgresql.org> <42D303CA.2020808@arbash-meinel.com> <42D31613.5020608@metatrontech.com> In-Reply-To: <42D31613.5020608@metatrontech.com> X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigEDC246B45A7210D61FBECEB2" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.038 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200507/117 X-Sequence-Number: 13358 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigEDC246B45A7210D61FBECEB2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Chris Travers wrote: > John A Meinel wrote: > >> jobapply wrote: >> >> >>> The 2 queries are almost same, but ORDER BY x||t is FASTER than ORDER >>> BY x.. >>> >>> How can that be possible? >>> >>> Btw: x and x||t are same ordered >>> >>> phoeniks=> explain analyze SELECT * FROM test WHERE i<20 ORDER BY x >>> || t; >>> QUERY PLAN >>> >>> >> >> >> What types are x and t, I have the feeling "x || t" is actually a >> boolean, so it is only a True/False sort, while ORDER BY x has to do >> some sort of string comparison (which might actually be a locale >> depended comparison, and strcoll can be very slow on some locales) >> >> >> > Am I reading this that wrong? I would think that x || t would mean > "concatenate x and t." Sorry, I think you are right. I was getting my operators mixed up. > > This is interesting. I never through of writing a multicolumn sort this > way.... I'm also surprised that the sort is faster with a merge operation. Are you using UNICODE as the database format? I'm just wondering if it is doing something funny like casting it to an easier to sort type. > > Best Wishes, > Chris Travers > Metatron Technology Consulting PS> Don't forget to Reply All so that your messages go back to the list. --------------enigEDC246B45A7210D61FBECEB2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Darwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFC0yF8JdeBCYSNAAMRAuLoAKCQRpqH4VQrgX1WYAPsdIkhvTGsIgCcDIsH X59AVC17LTtLbpt8i6BHxaw= =L2PD -----END PGP SIGNATURE----- --------------enigEDC246B45A7210D61FBECEB2--