go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/resultdb/script/sql/spanner/2022-02-07-clean-old-data-for-ttl.sql (about)

     1  -- Clean old data before setting TTL (go/resultdb-database-ttl). This gives us
     2  -- more control over the resource usage, instead of leaving it to the TTL
     3  -- background process. Row deletion policies run at a low priority, ideal for
     4  -- incremental clean-up.
     5  
     6  -- Delete old data over 1.5 years in Invocations table. The interleaved child
     7  -- rows in child tables (Artifacts, IncludedInvocations, TestExonerations,
     8  -- TestResultCounts) will be deleted atomically.
     9  --
    10  -- Execute via Partitioned DML for better performance:
    11  -- gcloud spanner databases execute-sql luci-resultdb \
    12  --     --project=luci-resultdb --instance=prod --enable-partitioned-dml \
    13  --     --sql='DELETE FROM Invocations WHERE TIMESTAMP_ADD(CreateTime, INTERVAL 547 DAY) < CURRENT_TIMESTAMP()'
    14  DELETE
    15  FROM Invocations
    16  WHERE TIMESTAMP_ADD(CreateTime, INTERVAL 540 DAY) < CURRENT_TIMESTAMP();