Re: Cost of sort/order by not estimated by the query planner - Mailing list pgsql-hackers

From Hitoshi Harada
Subject Re: Cost of sort/order by not estimated by the query planner
Date
Msg-id e08cc0400912022258mdb775fdp618f872c82f7276d@mail.gmail.com
Whole thread Raw
In response to Cost of sort/order by not estimated by the query planner  (Laurent Laborde <kerdezixe@gmail.com>)
Responses Re: Cost of sort/order by not estimated by the query planner  (Laurent Laborde <kerdezixe@gmail.com>)
List pgsql-hackers
2009/12/1 Laurent Laborde <kerdezixe@gmail.com>:
> The problem is in the order by, of course.
> If i remove the "order by" the LIMIT 5 is faster (0.044 ms) and do an
> index scan.
> At limit 500 (without order) it still use an index scan and it is
> slightly slower.
> At limit 5000 (without order) it switch to a Bitmap Index Scan +
> Bitmap Heap Scan and it's slower but acceptable (5.275 ms)
>
> Why, with the "QUERY 2", postgresql doesn't estimate the cost of the
> Sort/ORDER BY ?
> Of course, by ignoring the order, both query plan are right and the
> choice for thoses differents plans totally make sense.

It's because the result of IndexScan is already sorted by demanded
key, whereas the one of BitmapIndexScan isn't. But I'm not sure why
the query lasts more than 30 minutes...


Regards,

-- 
Hitoshi Harada


pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: pgbench: new feature allowing to launch shell commands
Next
From: Itagaki Takahiro
Date:
Subject: Re: ProcessUtility_hook