pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marcin Mirosław <marcin@mejor.pl>
To: pgsql-performance@postgresql.org
Subject: [planner] Ignore "order by" in subselect if parrent do count(*)
Date: Thu, 01 Mar 2012 12:45:28 +0100
Message-ID: <4F4F6158.7060200@mejor.pl> (raw)

Hello,
my example query (and explain) is:
$ explain SELECT count(*) from (select * from users_profile order by id)
u_p;
                                QUERY PLAN
---------------------------------------------------------------------------
 Aggregate  (cost=1.06..1.07 rows=1 width=0)
   ->  Sort  (cost=1.03..1.03 rows=2 width=572)
         Sort Key: users_profile.id
         ->  Seq Scan on users_profile  (cost=0.00..1.02 rows=2 width=572)
(4 rows)

Meseems "order by id" can be ignored by planner. It should speed up
query without side effect. I know the query should be fixed but this is
real and simplified query from real application.
Does postgresql team think ppostgres should be smarter than user and fix
user queries? If answer is positive please treat this as "feature request".
Thank you and regards,
Marcin.



view thread (9+ messages)  latest in thread

Message-ID: <4F4F6158.7060200@mejor.pl>
Permalink:  ../4F4F6158.7060200@mejor.pl/
Also on:    postgresql.org/message-id/4F4F6158.7060200@mejor.pl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: marcin@mejor.pl
  Subject: Re: [planner] Ignore "order by" in subselect if parrent do count(*)
  In-Reply-To: <4F4F6158.7060200@mejor.pl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox