From: | "Reinoud van Leeuwen" <reinoud(at)xs4all(dot)nl> |
---|---|
To: | <pgsql-hackers(at)postgresql(dot)org> |
Subject: | optimizer question |
Date: | 2001-09-26 12:53:14 |
Message-ID: | 23710.194.109.0.126.1001508794.squirrel@webmail.xs4all.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
I have a table that contains almost 8 milion rows. The primary key is a
sequence, so the index should have a good distribution. Why does the
optimizer refuse to use the index for getting the maximum value?
(even after a vacuum analyze of the table)
radius=# explain select max(radiuspk) from radius ;
NOTICE: QUERY PLAN:
Aggregate (cost=257484.70..257484.70 rows=1 width=8)
-> Seq Scan on radius (cost=0.00..237616.76 rows=7947176 width=8)
Table and key info:
Did not find any relation named "radius_pk".
radius=# \d radius
Table "radius"
Attribute | Type | Modifier
---------------------+--------------------------+---------------------------
sessionid | character varying(30) | not null
username | character varying(30) | not null
nas_ip | character varying(50) | not null
logfileid | integer |
login_ip_host | character varying(50) | not null
framed_ip_address | character varying(50) |
file_timestamp | timestamp with time zone | not null
corrected_timestamp | timestamp with time zone | not null
acct_status_type | smallint | not null
bytesin | bigint |
bytesout | bigint |
handled | boolean | not null default 'f'
sessionhandled | boolean | not null default 'f'
radiuspk | bigint | not null default nextval
('radiuspk_seq'::text)
Indices: pk_radius,
radius_us
radius=# \d pk_radius
Index "pk_radius"
Attribute | Type
-----------+--------
radiuspk | bigint
unique btree (primary key)
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Lockhart | 2001-09-26 13:08:48 | iscacheable for date/time? |
Previous Message | Thomas Lockhart | 2001-09-26 12:43:22 | Re: Unicode combining characters |