comparison schema/gemma.sql @ 4126:52f7264265bb

Bulk-delete tracked entries per table Especially when many entries in one table are tracked by one import, this makes declining an import a lot faster.
author Tom Gottfried <tom@intevation.de>
date Thu, 01 Aug 2019 17:02:09 +0200
parents 7711486efaba
children 8c62809ea87e
comparison
equal deleted inserted replaced
4125:0f69d256fa12 4126:52f7264265bb
879 $$ 879 $$
880 DECLARE 880 DECLARE
881 tmp RECORD; 881 tmp RECORD;
882 BEGIN 882 BEGIN
883 FOR tmp IN 883 FOR tmp IN
884 SELECT * FROM import.track_imports WHERE import_id = imp_id AND NOT deletion 884 SELECT relation, array_agg(key) AS keys
885 FROM import.track_imports
886 WHERE import_id = imp_id AND NOT deletion
887 GROUP BY relation
885 LOOP 888 LOOP
886 EXECUTE format('DELETE FROM %s WHERE id = $1', tmp.relation) USING tmp.key; 889 EXECUTE format('DELETE FROM %s WHERE id = ANY($1)', tmp.relation)
890 USING tmp.keys;
887 END LOOP; 891 END LOOP;
888 END; 892 END;
889 $$ 893 $$
890 LANGUAGE plpgsql; 894 LANGUAGE plpgsql;
891 895