Does the table layout / order in the FROM section support any difference in performance improvement?

In general, does the arrangement or order of the tables in the FROM clause make any difference in improving query performance? By agreement, I mean the smallest table and the largest table.

Any other experience / ideas / opinions / factors are also welcome.

In my case, we are using PostgreSQL v8.2.3.

+5
source share
4 answers

For internal joins this should not make any difference: the optimizer will generate plans that perform joins as many different orders as possible (up to the geqo_threshold tables in the from clause).

, ( ).

+4

- "SELECT FROM table1, table2"? "" , , .

, , , EXPLAIN, , ?

+2

( SQL, Postgre)

- , SQL, , , , .. .

, ( , , ..), ​​.

0
source

If you write FROM foo, bar, baz, then no, it does not matter. If you write FROM foo JOIN bar ... JOIN baz ...(internal connections), then it does not matter if you have fewer join_collapse_limitelements; otherwise, the connection order is fixed, which you can use to manually optimize such things (but this is rarely necessary). For external joins, the join order is fixed because it is written because it affects the results.

0
source

All Articles