From: | Szymon Guz <mabewlun(at)gmail(dot)com> |
---|---|
To: | Marcin Mirosław <marcin(at)mejor(dot)pl> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: [planner] Ignore "order by" in subselect if parrent do count(*) |
Date: | 2012-03-01 11:50:08 |
Message-ID: | CAFjNrYvECD+kDVfo76s8zHsfb0E0G7CkGH2boyHT7rgpkFBS7Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On 1 March 2012 12:45, Marcin Mirosław <marcin(at)mejor(dot)pl> wrote:
> 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.
>
>
If you have only 2 rows in the table, then the plan really doesn't matter
too much. Sorting two rows would be really fast :)
Try to check it with 10k rows.
regards
Szymon
From | Date | Subject | |
---|---|---|---|
Next Message | Marcin Mirosław | 2012-03-01 12:02:24 | Re: [planner] Ignore "order by" in subselect if parrent do count(*) |
Previous Message | Marcin Mirosław | 2012-03-01 11:45:28 | [planner] Ignore "order by" in subselect if parrent do count(*) |