Re: SELECT MIN, MAX took longer time than SELECT

From: K C Lau <kclau60(at)netvigator(dot)com>
To: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: SELECT MIN, MAX took longer time than SELECT
Date: 2006-01-21 13:12:47
Message-ID: 6.2.1.2.0.20060121210512.08cc9310@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

At 01:20 06/01/21, Jim C. Nasby wrote:

>BTW, these queries below are meaningless; they are not equivalent to
>min(logsn).
>
> > esdt=> explain analyze select LogSN from Log where create_time <
> > '2005/10/19' order by create_time limit 1;

Thank you for pointing it out.

It actually returns the min(logsn), as the index is on (create_time,
logsn). To be more explicit, I have changed to query to:
explain analyze select LogSN from Log where create_time < '2005/10/19'
order by create_time, logsn limit 1;

esdt=> \d log;
create_time | character varying(23) | default
'1970/01/01~00:00:00.000'::character varying
logsn | integer | not null
...
Indexes:
"pk_log" PRIMARY KEY, btree (logsn)
"idx_logtime" btree (create_time, logsn)

Best regards,
KC.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Oleg Bartunov 2006-01-21 13:29:13 Re: [GENERAL] Creation of tsearch2 index is very slow
Previous Message Martijn van Oosterhout 2006-01-21 13:08:30 Re: [GENERAL] Creation of tsearch2 index is very slow