X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 8A74F9DC803 for ; Sat, 21 Jan 2006 09:27:30 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63606-03 for ; Sat, 21 Jan 2006 09:27:33 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from imsm057dat.netvigator.com (imsm057.netvigator.com [218.102.48.210]) by postgresql.org (Postfix) with ESMTP id 5CF8C9DC802 for ; Sat, 21 Jan 2006 09:27:26 -0400 (AST) Received: from n2.netvigator.com ([218.102.95.109]) by imsm057dat.netvigator.com (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id <20060121132728.NZZW14795.imsm057dat.netvigator.com@n2.netvigator.com>; Sat, 21 Jan 2006 21:27:28 +0800 Received: from n2.netvigator.com ([127.0.0.1]) by [127.0.0.1] with ESMTP (SpamPal v1.591) sender ; 21 Jan 2006 21:27:28 +???? Message-Id: <6.2.1.2.0.20060121210512.08cc9310@localhost> X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 Date: Sat, 21 Jan 2006 21:12:47 +0800 To: "Jim C. Nasby" From: K C Lau Subject: Re: SELECT MIN, MAX took longer time than SELECT Cc: pgsql-performance@postgresql.org In-Reply-To: <20060120172026.GF20182@pervasive.com> References: <6.2.1.2.0.20060120120150.08ab7b00@localhost> <20060120172026.GF20182@pervasive.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.2 required=5 tests=[AWL=-0.240, DNS_FROM_RFC_POST=1.44] X-Spam-Score: 1.2 X-Spam-Level: * X-Archive-Number: 200601/387 X-Sequence-Number: 16865 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.