From: | "David Rowley" <dgrowley(at)gmail(dot)com> |
---|---|
To: | "'Hitoshi Harada'" <umi(dot)tanuki(at)gmail(dot)com> |
Cc: | <pgsql-hackers(at)postgresql(dot)org>, <heikki(dot)linnakangas(at)enterprisedb(dot)com>, <sitnikov(dot)vladimir(at)gmail(dot)com> |
Subject: | Re: Windowing Function Patch Review -> Performance Comparison. |
Date: | 2008-11-09 22:31:03 |
Message-ID: | FACFEF332E594B2E9122B155925D6425@amd64 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hitoshi Harada wrote:
> I found how to do it, though it's only on the case you gave. Thinking
> about the planner optimization of the Window nodes (and its attached
> Sort nodes), we must consider the execution order of more than one
> node. In the test case we only take care of only one window, but there
> may be more window/sort node sets, which is too difficult to choose
> the best execution order including the downer indexscan, mergejoin in
> subquery and sort-based GROUP BY. So I didn't touch the complicated
> planner jungle. I rewrote the patch so that only the given bottom
> window's sort can consider indexscan. Deeper optimizations are over my
> capability.
After more playing around with a few queries and testing some performance of
larger tables. I discovered something strange in the plan for this query.
david=# explain select date,lag(date,1) over (order by date) from
meter_Readings order by date;
QUERY PLAN
----------------------------------------------------------------------------
--------------------------------
Sort (cost=1038.73..1063.74 rows=10001 width=4)
Sort Key: date
-> Window (cost=0.00..374.27 rows=10001 width=4)
-> Index Scan using meter_readings_pkey on meter_readings
(cost=0.00..299.27 rows=10001 width=4)
(4 rows)
Is the final sort still required? Is it not already sorted in the window?
The table I was testing on split the sort to disk, I would probably not have
noticed otherwise.
David.
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Joseph Krogh | 2008-11-09 23:30:33 | Re: Windowing Function Patch Review -> ROW_NUMBER without ORDER BY |
Previous Message | Tom Lane | 2008-11-09 22:12:46 | Re: Reducing some DDL Locks to ShareLock |