Re: [planner] Ignore "order by" in subselect if parrent do count(*)

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: Marcin Miros*aw <marcin(at)mejor(dot)pl>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: [planner] Ignore "order by" in subselect if parrent do count(*)
Date: 2012-03-01 16:50:57
Message-ID: 4F4F54910200002500045D59@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Marcin Miros*aw<marcin(at)mejor(dot)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

In response to

Responses

Browse pgsql-performance by date

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