Re: Indexes not used for "min()"

Lists: Postg토토 핫SQL : Postg토토 핫SQL 메일 링리스트 : 2003-08-04 이후 PGSQL-BUGS 20:58
From: "Valsecchi, Patrick" <patrick(dot)valsecchi(at)nagrastar(dot)com>
To: <pgsql-bugs(at)postgresql(dot)org>
Subject: Indexes not used for "min()"
Date: 2003-07-29 15:48:37
Message-ID: 4E2CE3FB9E1B744482F6669A9AE2F72E68F08B@NSTAREXCH1.windows.nagrastar.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: Postg스포츠 토토 결과SQL : Postg스포츠 토토 결과SQL 메일 링리스트 : 2003-07-29 이후 PGSQL-BUGS 15:48

Your name : Patrick
Your email address : Valsecchi

System Configuration
---------------------
Architecture (example: Intel Pentium) : Intel Pentium

Operating System (example: Linux 2.0.26 ELF) : Linux 2.4.20

PostgreSQL version (example: PostgreSQL-7.3.3): PostgreSQL-7.3.3

Compiler used (example: gcc 2.95.2) : gcc 3.2

Please enter a FULL description of your problem:
------------------------------------------------

When doing the following query, it's obvious that postgres should use
the index:

stats=# explain select min(time) from call;
QUERY PLAN
------------------------------------------------------------------------
Aggregate (cost=49779.82..49779.82 rows=1 width=8)
-> Seq Scan on stb_call (cost=0.00..44622.06 rows=2063106 width=8)
(2 rows)

stats=# \d call
Table "public.call"
Column | Type | Modifiers
---------+--------------------------+-----------
a | integer | not null
b | integer | not null
time | timestamp with time zone | not null
d | character varying(4) |
e | character varying(4) |
f | character varying(4) |
g | character varying(15) | not null
h | character varying(7) |
i | smallint | not null
Indexes: call_time btree ("time")

stats=# select count(*) from call;
count
---------
2063106
(1 row)

If you have any question or comment, please contact me directly, I'm not
suscribed to the list.


From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: "Valsecchi, Patrick" <patrick(dot)valsecchi(at)nagrastar(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Indexes not used for "min()"
Date: 2003-08-04 20:58:15
Message-ID: 20030804205815.GA14136@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: Postg토토 핫SQL : Postg토토 핫SQL 메일 링리스트 : 2003-08-04 이후 PGSQL-BUGS 20:58

On Tue, Jul 29, 2003 at 09:48:37 -0600,
"Valsecchi, Patrick" <patrick(dot)valsecchi(at)nagrastar(dot)com> wrote:
>
> When doing the following query, it's obvious that postgres should use
> the index:
>
> stats=# explain select min(time) from call;

This has been discussed on the mailing lists numerous times. If you are
interested in details you can search the archives. If you just want a faster
equivalent query use:
select time from call order by time limit 1;