Re: SELECT MIN, MAX took longer time than SELECT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux