Re: Why DISTINCT ... DESC is slow?

From: Anton <anton200(at)gmail(dot)com>
To: "Ron Johnson" <ron(dot)l(dot)johnson(at)cox(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Why DISTINCT ... DESC is slow?
Date: 2006-12-13 05:13:47
Message-ID: 8cac8dd0612122113q761eddb0xdd66c128e85c666c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> > =# \d n_traffic
> > Table "public.n_traffic"
> > Column | Type | Modifiers
> > --------------+-----------------------------+------------------------------
> > login_id | integer | not null
> > traftype_id | integer | not null
> > collect_time | timestamp without time zone | not null default now()
> > bytes_in | bigint | not null default (0)::bigint
> > bytes_out | bigint | not null default (0)::bigint
> > Indexes:
> > "n_traffic_collect_time" btree (collect_time)
> > "n_traffic_login_id" btree (login_id)
> > "n_traffic_login_id_collect_time" btree (login_id, collect_time)
> > Foreign-key constraints:
> > "n_traffic_login_id_fkey" FOREIGN KEY (login_id) REFERENCES
> > n_logins(login_id) ON UPDATE CASCADE
> > "n_traffic_traftype_id_fkey" FOREIGN KEY (traftype_id) REFERENCES
> > n_traftypes(traftype_id) ON UPDATE CASCADE
>
> 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.

> ISTM that you can drop the LOGIN_ID index.
--
engineer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2006-12-13 07:53:00 Re: TIMESTAMP WITHOUT TIME ZONE
Previous Message Tom Lane 2006-12-13 03:48:10 Re: resetting sequence to cur max value