pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John A Meinel <john@arbash-meinel.com>
To: Chris Travers <chris@metatrontech.com>
To: Postgresql Performance <pgsql-performance@postgresql.org>
Subject: Re: Sorting on longer key is faster ?
Date: Mon, 11 Jul 2005 20:48:44 -0500
Message-ID: <42D3217C.20703@arbash-meinel.com> (raw)
In-Reply-To: <42D31613.5020608@metatrontech.com>
References: <20050709183842.2EABF52820@svr1.postgresql.org>
	<42D303CA.2020808@arbash-meinel.com>
	<42D31613.5020608@metatrontech.com>

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.

Attachments:

  signature.asc (application/pgp-signature, 252B) download

view thread (5+ messages)  latest in thread

Message-ID: <42D3217C.20703@arbash-meinel.com>
Permalink:  ../42D3217C.20703@arbash-meinel.com/
Also on:    postgresql.org/message-id/42D3217C.20703@arbash-meinel.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: john@arbash-meinel.com, chris@metatrontech.com
  Subject: Re: Sorting on longer key is faster ?
  In-Reply-To: <42D3217C.20703@arbash-meinel.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox