Re: Why DISTINCT ... DESC is slow? - Mailing list pgsql-general

From Ron Johnson
Subject Re: Why DISTINCT ... DESC is slow?
Date
Msg-id 45800737.3050103@cox.net
Whole thread Raw
In response to Re: Why DISTINCT ... DESC is slow?  (Anton <anton200@gmail.com>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/12/06 23:13, Anton wrote:
[snip]
>> Why do you have indexes on both LOGIN_ID *and* LOGIN_ID +
>> COLLECT_TIME?
> It is because I think that queries which use only LOGIN_ID field
> will use (faster) LOGIN_IDonly index... For me, speed of
> insertions is not a primary task here (robot is not confused by
> delays...), but select is. So I keep both indexes.

Figured.  Understandable thought, and valid for a *hashed* index.
Also valid for COLLECT_TIME, since it's the 2nd segment of the index.

Because of the nature of b-tree indexes, though, the optimizer
*will* use n_traffic_login_id_collect_time when you say WHERE
LOGIN_ID = 5;

>> ISTM that you can drop the LOGIN_ID index.


- --
Ron Johnson, Jr.
Jefferson LA  USA

Is "common sense" really valid?
For example, it is "common sense" to white-power racists that
whites are superior to blacks, and that those with brown skins
are mud people.
However, that "common sense" is obviously wrong.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFFgAc3S9HxQb37XmcRAnGPAKCgRBJ1ADJ/chYqIDZhVdZhwKB6YQCeNevb
+DnTXM/8utMXyN5s+zA//lU=
=DKb/
-----END PGP SIGNATURE-----

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: grant select on all tables of schema or database
Next
From: "Merlin Moncure"
Date:
Subject: Re: PG Admin