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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux