From: John A Meinel <john@arbash-meinel.com>
To: jobapply <jobapply@nextmail.ru>
Cc: pgsql-performance@postgresql.org
Subject: Re: Sorting on longer key is faster ?
Date: Mon, 11 Jul 2005 20:52:25 -0500
Message-ID: <42D32259.2000705@arbash-meinel.com> (raw)
In-Reply-To: <20050709183842.2EABF52820@svr1.postgresql.org>
References: <20050709183842.2EABF52820@svr1.postgresql.org>
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
I also thought of another possibility. Are there a lot of similar
entries in X? Meaning that the same value is repeated over and over? It
is possible that the sort code has a weakness when sorting equal values.
For instance, if it was doing a Hash aggregation, you would have the
same hash repeated. (It isn't I'm just mentioning a case where it might
affect something).
If it is creating a tree representation, it might cause some sort of
pathological worst-case behavior, where all entries keep adding to the
same side of the tree, rather than being more balanced.
I don't know the internals of postgresql sorting, but just some ideas.
John
=:->
Attachments:
signature.asc (application/pgp-signature, 252B) download
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, jobapply@nextmail.ru
Subject: Re: Sorting on longer key is faster ?
In-Reply-To: <42D32259.2000705@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