4 Quick and dirty pl/pgsql function to split full / large table updates into
5 chunks and perform intermediate vacuums.
7 Connects via dblink to perform individual transactions.
13 in_nspname -- Schema containing the table
14 in_relname -- Table name
15 in_fields -- The field names to update comma separated *
16 in_values -- The values for the corresponding field names *
17 in_where_clause -- Any where clause for the update *
18 in_chunks -- Break the update into this many chunks
19 in_conninfo -- database conninfo to pass to dblink
22 * Arguments for in_fields, in_values and in_where_clause are plain text and not
23 sanitized in any way, so ensure tight permissions to prevent sql injection.
27 For vacuum to do it's work best we should not have a long running transaction
28 in the database containing the table, so best to switch to another database:
32 You are now connected to database "postgres"
33 postgres=# SELECT pg_chunk_update('public', 'test', 'b', E'\'SOMETHING ELSE \' || a', 'a > 500000', 200, 'dbname=TEST user=glyn');