Pavel Stehule <pavel.steh...@gmail.com> writes: > I am solving a strange situation, where using a view is slower than > using same tables directly.
> The view is defined as > CREATE VIEW v1 AS > SELECT * > FROM A > LEFT JOIN B > LEFT JOIN C > LEFT JOIN D > and query is > SELECT * > FROM T > LEFT JOIN v > this query is slower than: > SELECT * > FROM T > LEFT JOIN A > LEFT JOIN B > LEFT JOIN C > LEFT JOIN D > Is there a some reason for this behave? Well, they don't necessarily mean the same thing --- these are only logically equivalent if the left joins all commute, which would depend on the ON conditions. > [ EXPLAIN outputs ] But I also notice that you are using collapse/geqo limits of 12 for queries that involve 13 base relations, so that'd mean that syntactic differences could lead to plan differences too. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers