From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | Mario Weilguni <mweilguni(at)sime(dot)com> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: strange query plan |
Date: | 2001-04-08 11:50:44 |
Message-ID: | Pine.LNX.4.30.0104081349000.1236-100000@peter.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs pgsql-general |
Mario Weilguni writes:
> 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.
Since your query reads the entire "log" table, it is certainly better to
use a sequential scan in the case of sum() and avg(). A min() and max()
would theoretically not need to scan the entire table in the presence of
an index, but unfortunately this doesn't work yet.
--
Peter Eisentraut peter_e(at)gmx(dot)net http://yi.org/peter-e/
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Clift | 2001-04-08 12:38:18 | Re: Re: [GENERAL] Better Features document? |
Previous Message | Peter Eisentraut | 2001-04-08 11:15:37 | Re: [GENERAL] Better Features document? |
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Clift | 2001-04-08 12:38:18 | Re: Re: [GENERAL] Better Features document? |
Previous Message | Peter Eisentraut | 2001-04-08 11:15:37 | Re: [GENERAL] Better Features document? |