From: | Marc Cousin <cousinmarc(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: star schema and the optimizer |
Date: | 2015-02-27 19:01:02 |
Message-ID: | 54F0BEEE.3020604@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 27/02/2015 19:45, Tom Lane wrote:
>> I wrote:
>>> I had actually thought that we'd fixed this type of problem in recent
>>> versions, and that you should be able to get a plan that would look like
>
>>> Nestloop
>>> -> scan dim1
>>> -> Nestloop
>>> -> scan dim2
>>> -> indexscan fact table using dim1.a and dim2.b
>
> After closer study, I think this is an oversight in commit
> e2fa76d80ba571d4de8992de6386536867250474, which quoth
>
> +It can be useful for the parameter value to be passed down through
> +intermediate layers of joins, for example:
> +
> + NestLoop
> + -> Seq Scan on A
> + Hash Join
> + Join Condition: B.Y = C.W
> + -> Seq Scan on B
> + -> Index Scan using C_Z_IDX on C
> + Index Condition: C.Z = A.X
> +
> +If all joins are plain inner joins then this is unnecessary, because
> +it's always possible to reorder the joins so that a parameter is used
> +immediately below the nestloop node that provides it. But in the
> +presence of outer joins, join reordering may not be possible, and then
> +this option can be critical. Before version 9.2, Postgres used ad-hoc
>
> This reasoning overlooked the fact that if we need parameters from
> more than one relation, and there's no way to join those relations
> to each other directly, then we have to allow passing the dim1 parameter
> down through the join to dim2.
>
> The attached patch seems to fix it (modulo the need for some updates
> in the README, and maybe a regression test). Could you see if this
> produces satisfactory plans for you?
From what I see, it's just perfect. I'll give it a more thorough look a
bit later, but it seems to be exactly what I was waiting for.
Thanks a lot.
Regards
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2015-02-27 19:04:37 | Re: Providing catalog view to pg_hba.conf file - Patch submission |
Previous Message | Alvaro Herrera | 2015-02-27 18:50:42 | Re: logical column ordering |