Revision 10930
Added by Aaron Marcuse-Kubitza about 11 years ago
postprocess.sql | ||
---|---|---|
4 | 4 |
SELECT "*TREE-row_num" AS "occurrence_all-row_num", * |
5 | 5 |
/* directional joins ensure that the PostgreSQL query planner always joins |
6 | 6 |
starting with the TREE table */ |
7 |
FROM ("REF_RESEARCH_STATION" |
|
8 |
NATURAL RIGHT JOIN ("REF_UNIT" |
|
9 |
NATURAL RIGHT JOIN ("COUNTY" |
|
10 |
NATURAL RIGHT JOIN ("PLOT" |
|
11 |
NATURAL RIGHT JOIN ("COND" |
|
12 |
NATURAL LEFT JOIN "REF_HABTYP_DESCRIPTION" |
|
13 |
NATURAL RIGHT JOIN ("SUBPLOT" |
|
14 |
NATURAL RIGHT JOIN ("TREE" |
|
15 |
NATURAL LEFT JOIN "REF_SPECIES" |
|
16 |
NATURAL LEFT JOIN "REF_PLANT_DICTIONARY" |
|
17 |
))))))) |
|
7 |
FROM "TREE" |
|
8 |
NATURAL LEFT JOIN "REF_SPECIES" |
|
9 |
NATURAL LEFT JOIN "REF_PLANT_DICTIONARY" |
|
10 |
NATURAL LEFT JOIN "SUBPLOT" |
|
11 |
NATURAL LEFT JOIN "COND" |
|
12 |
NATURAL LEFT JOIN "REF_HABTYP_DESCRIPTION" |
|
13 |
NATURAL LEFT JOIN "PLOT" |
|
14 |
NATURAL LEFT JOIN "COUNTY" |
|
15 |
NATURAL LEFT JOIN "REF_UNIT" |
|
16 |
NATURAL LEFT JOIN "REF_RESEARCH_STATION" |
|
18 | 17 |
$$); |
19 | 18 |
|
20 | 19 |
SELECT mk_subset_by_row_num_func('"occurrence_all"', 'occurrence_all-row_num'); |
Also available in: Unified diff
inputs/FIA/occurrence_all/postprocess.sql: use much simpler LEFT JOINs instead of nested RIGHT JOINs, which required lots of () to get them to happen in the right order. note that the columns are now provided in reverse instead of forwards path order, but this is still much clearer than the nested mess of RIGHT JOINs. this approach can also be used to simplify VegBank's joins.