This is the first iteration for keeping the tree data in the database.
This PR introduces two new tables, trees and trees_staging.
The trees table would ideally replace the treedata table. The treedata table is currently a mix of time based data and reference data. There was a discussion around normalizing it further. However, we can also use the original treedata table instead of the proposed tree table with minimal updates. There is a migration file that shows how the data is interchangeable between those two.
The trees_staging table is a unlogged table. This is similar to a temporary table in that there is no write to the WAL. It differs in that the data is global. This means you can write with one connection and then use that data with another. A temporary table would need to maintain data and operations on the same connection, which is a problem when using something like ogr2ogr for writing data.
There is also a stored procedure that merges the two tables. This does the full upsert logic in three parts using a temporary table. The procedure is idempotent.
This is the first iteration for keeping the tree data in the database.
This PR introduces two new tables,
trees
andtrees_staging
. Thetrees
table would ideally replace thetreedata
table. Thetreedata
table is currently a mix of time based data and reference data. There was a discussion around normalizing it further. However, we can also use the originaltreedata
table instead of the proposedtree
table with minimal updates. There is a migration file that shows how the data is interchangeable between those two. Thetrees_staging
table is a unlogged table. This is similar to a temporary table in that there is no write to the WAL. It differs in that the data is global. This means you can write with one connection and then use that data with another. A temporary table would need to maintain data and operations on the same connection, which is a problem when using something likeogr2ogr
for writing data. There is also a stored procedure that merges the two tables. This does the full upsert logic in three parts using a temporary table. The procedure is idempotent.