Re: Optimizer picks an ineffient plan

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Optimizer picks an ineffient plan
Date: 2003-09-03 22:56:54
Message-ID: 871xuxcwg9.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


"Bupp Phillips" <hello(at)noname(dot)com> writes:

> but...
>
> select * from customer order by customer_id, first_name;
> QUERY PLAN:
> Sort(cost=142028.25..142028.25 rows=102834 width=724)
> -> Seq Scan on customer (cost=0.00..4617.34 rows=102834 width=724)
> Total runtime: 19999.81 msec

Actually in this case the optimizer would likely still use a sequential scan
even if it had an index it thought it could use. If you're going to be reading
the whole table anyways it'll be faster to read it in order than to jump all
around even if you have to sort it.

However you do have a point. In this case I don't think postgres even
considers using the index. Even if it would decide not to use it in this case
there could conceivably be cases where it would want to use it.

However I'm not sure I see a lot of cases where this would come up. Even in
automatically generated code, which is the usual cause of redundant things
like this, I don't think I've seen this particular combination ever come up.

--
greg

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2003-09-03 23:01:56 Re: Localization (for dates) Oracle vs. Postgresql
Previous Message Bruce Momjian 2003-09-03 22:42:31 Re: setting last_value of sequence