...
Code Block | ||
---|---|---|
| ||
DO $$ DECLARE delete_before DATE := '2000-12-31'; BEGIN DELETE FROM "Contexts" WHERE "ContextType" = 'ElementContext' AND "FlowContextId" IN (SELECT "Id" FROM "Contexts" WHERE "FlowContextIdContextType" IS= NULL'FlowContext' AND "CreateTime" < delete_before); DELETE FROM "ContextIndices" WHERE "FlowContextId" IN (SELECT "Id" FROM "Contexts" WHERE "FlowContextIdContextType" IS= NULL'FlowContext' AND "CreateTime" < delete_before); DELETE FROM "ContextLogs" WHERE "FlowContextId" IN (SELECT "Id" FROM "Contexts" WHERE "FlowContextIdContextType" IS= NULL'FlowContext' AND "CreateTime" < delete_before); DELETE FROM "Contexts" WHERE "FlowContextIdContextType" IS= NULL'FlowContext' AND "CreateTime" < delete_before; DELETE FROM "PerformanceRecords" WHERE "Time" < delete_before; END $$; REINDEX TABLE "Contexts"; REINDEX TABLE "ContextIndices"; REINDEX TABLE "ContextLogs"; REINDEX TABLE "PerformanceRecords"; |
...