SELECT util.search_path_append('util'); SELECT create_if_not_exists( $$CREATE INDEX $$||(:table_str||%'__accessRights')||$$ ON $$||:table_str||$$ ("accessRights")$$) ; -- runtime: 4 s ("3596.509 ms") @frenzy, 3 s ("2533.529 ms") @vegbiendev -- remove private data DELETE FROM :table WHERE "accessRights" = 'private' ; -- 112 rows (174042 - 173930)