From: | Mario Weilguni <mweilguni(at)sime(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | strange query plan |
Date: | 2001-04-08 08:35:00 |
Message-ID: | 01040810350000.00637@wotan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs pgsql-general |
I've a table containing some sort of logs, the table layout ist:
Attribute | Type | Modifier
-----------+--------------------------+---------------------------------------
id | integer | not null default nextval('ids'::text)
serverid | integer | not null
ts | timestamp with time zone | default now()
log | character varying(400) | not null
Indices: i1,
log_pkey
primary key is id, and there is an additional index on serverid. The table
contains ~ 1.4 mio of rows, I've used "vacuum analyze".
Now when I type:
explain select min(id)from log;
NOTICE: QUERY PLAN:
Aggregate (cost=45702.20..45702.20 rows=1 width=4)
-> Seq Scan on log (cost=0.00..41978.36 rows=1489536 width=4)
I don't understand why the index log_pkey is not used here. I guess it would
be much cheaper to consult the index to get min(), max(), sum() and avg()
instead of sequentially scanning ~500MB of data.
Any idea?
Thanks
Best regards,
Mario Weilguni
--
===================================================
Mario Weilguni KPNQwest Austria GmbH
Senior Engineer Web Solutions Nikolaiplatz 4
tel: +43-316-813824 8020 graz, austria
fax: +43-316-813824-26 http://www.kpnqwest.at
e-mail: mario(dot)weilguni(at)kpnqwest(dot)com
===================================================
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2001-04-08 11:15:37 | Re: [GENERAL] Better Features document? |
Previous Message | Justin Clift | 2001-04-08 07:28:35 | www.postgresql.org down? |
From | Date | Subject | |
---|---|---|---|
Next Message | Louis-David Mitterrand | 2001-04-08 09:10:06 | Re: [GENERAL] Re: Permissons on database |
Previous Message | Eric G. Miller | 2001-04-08 07:30:51 | Re: Inheritance and referential integritry in 7.0.3 |