Re: [planner] Ignore "order by" in subselect if parrent do count(*) - Mailing list pgsql-performance

From Kevin Grittner
Subject Re: [planner] Ignore "order by" in subselect if parrent do count(*)
Date
Msg-id 4F4F54910200002500045D59@gw.wicourts.gov
Whole thread Raw
In response to [planner] Ignore "order by" in subselect if parrent do count(*)  (Marcin Mirosław <marcin@mejor.pl>)
Responses Re: [planner] Ignore "order by" in subselect if parrent do count(*)
List pgsql-performance
Marcin Miros*aw<marcin@mejor.pl> wrote:

> SELECT count(*)
>   from (select * from users_profile order by id) u_p;

> "order by id" can be ignored by planner.

This has been discussed before.  Certainly not all ORDER BY clauses
within query steps can be ignored, so there would need to be code to
determine whether it was actually useful, which wouldn't be free,
either in terms of planning time or code maintenance.  It wasn't
judged to be worth the cost.  If you want to avoid the cost of the
sort, don't specify ORDER BY where it doesn't matter.

-Kevin

pgsql-performance by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Bad estimation for "where field not in"
Next
From: Jeff Janes
Date:
Subject: Re: PG as in-memory db? How to warm up and re-populate buffers? How to read in all tuples into memory?