Table order at FROM clause affects performance?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a strange performance issue, i think that is not possible:

Given this statement:

SELECT several_fields  FROM A, B, C WHERE  conditions
A, B are tables with several LEFT JOINS but they act as one subquery.

If I execute the select above:

SELECT several_fields  FROM A, B, C WHERE  conditions
Time: 30 secs
Cost: 1M


If I execute the same select (same parameters) but swapping A and B in the from clause:

SELECT several_fields  FROM B, A, C WHERE  conditions
Time: 19ms

Cost: 10k

The plan changes dramatically: I can't see why the order of FROM clause impacts directly on the query cost and plan. If this is possible, where i can read about it? I need to know how the order of FROM clause modifies the query plan.

Thanks in advance. This is my first post.

Eduard Català







[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux