From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Thomas Mayer <thomas(dot)mayer(at)student(dot)kit(dot)edu> |
Cc: | pgsql-performance <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: window function induces full table scan |
Date: | 2014-01-03 18:04:13 |
Message-ID: | 4827.1388772253@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Thomas Mayer <thomas(dot)mayer(at)student(dot)kit(dot)edu> writes:
> ... "mark" ...: Do I understand you correctly, that you prefer doing the
> decision elsewhere and store the result (safe/unsafe) boolean value
> besides to the subquery output fields? For the push-down, a subquery
> output field must be available anyways.
See check_output_columns(). The infrastructure for deciding whether
a potentially-pushable qual refers to any unsafe subquery outputs already
exists; we just need to extend it to consider outputs unsafe if they
don't appear in all PARTITION BY lists.
>> Offhand I think the details of testing whether a given output column
>> appears in a given partition clause are identical to testing whether
>> it appears in the distinctClause. So you'd just be mechanizing running
>> through the windowClause list to verify whether this holds for all
>> the WINDOW clauses.
> When a field is element of all PARTITION BY clauses of all window
> functions, it does not mean that this field is distinct.
No, I didn't say that. What I meant was that (a) the is_pushdown_safe
logic can treat non-partitioning subquery outputs much like non-DISTINCT
outputs, and (b) the parsetree representation of PARTITION BY is enough
like DISTINCT ON that the same kind of test (viz, a targetIsInSortList
call) will serve.
I think you need to read the code around subquery_is_pushdown_safe and
qual_is_pushdown_safe some more.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Mayer | 2014-01-03 18:25:24 | Re: window function induces full table scan |
Previous Message | Thomas Mayer | 2014-01-03 17:44:50 | Re: window function induces full table scan |