I´ve a Postgres instance running in a 16 cores/32 Gb WIndows Server workstation.
I followed performance improvements tips I saw in places like this: https://www.postgresql.org/docs/9.3/static/performance-tips.html.
When I run an update like:
analyze;
update amazon_v2
set states_id = amazon.states_id,
geom = amazon.geom
from amazon
where amazon_v2.fid = amazon.fid
where fid is the primary key in both tables and both has 68M records, it takes almost a day to run.
Is there any way to improve the performance of SQL sentences like this? Should I write a stored procedure to process it record by record, for example?
analyzebefore update?and (amazon_v2.states_id <> amazon.states_id or amazon_v2.geom <> amazon.geom)to reduce the number of rows that need to be changedstates_idfield? If a lots of rows in amazon_v2 are getting updated with a different value forstates_idyou might want to drop the index(if present) on states_id and then rebuild it after your updatecreate tablestatements for the tables in question (including all indexes), the query you are using and the execution plan generated usingexplain (verbose). Formatted text please, no screen shots