mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 19:59:54 -05:00
### Does this PR have any customer impact? ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) ### Are you introducing any new config? If yes, do you have tests with and without them being set? ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) ### Description [OSS] Fix TTL indexes in documentdb This moves the function to C and instead of querying the indexes and then getting the collection shards from pg_dist_shard table, it uses the C hook to get the table shards where for non-distributed it returns the base table and then uses that information to drop the expired records. ---- #### AI description (iteration 1) #### PR Classification Bug fix #### PR Summary This pull request addresses issues with TTL indexes in DocumentDB by refactoring and optimizing the deletion of expired rows. - `ttl_index.c`: Refactored the function to delete expired rows, added a new function `delete_expired_rows`, and optimized the deletion process. - `ttl_support_functions--latest.sql` and `delete_expired_rows--latest.sql`: Replaced PL/pgSQL procedures with C language implementations for better performance. - `collection.c`: Moved the function `GetMongoCollectionShardOidsAndNames` from `coll_stats.c` to `collection.c` for better organization.
12 lines
450 B
PL/PgSQL
12 lines
450 B
PL/PgSQL
#include "udfs/metadata/list_databases--0.102-0.sql"
|
|
#include "udfs/ttl/ttl_support_functions--0.102-0.sql"
|
|
|
|
-- Schedule TTL Cron job to prune TTL indexes on every documentdb instance.
|
|
DO LANGUAGE plpgsql $cmd$
|
|
BEGIN
|
|
IF NOT EXISTS(SELECT 1 FROM cron.job where jobname = 'documentdb_ttl_task') THEN
|
|
PERFORM cron.schedule('documentdb_ttl_task', '* * * * *', $$CALL documentdb_api_internal.delete_expired_rows();$$);
|
|
END IF;
|
|
END;
|
|
$cmd$;
|