stac-utils / stac-utils/pgstac
Eliminate redundant partition stats update
Nobody has claimed this yet.
- Dominant language
- PLpgSQL
- Stars
- 223
- Forks
- 57
- PR merge metrics
- No merged PRs in 30d
Description
The update_partition_stats_q function is being invoked from load_partition in the pypgstac. However, this function is also being automatically triggered by changes to the items table:
postgis=> \dS items;
...
Triggers:
items_after_delete_trigger AFTER UPDATE ON items REFERENCING NEW TABLE AS newdata FOR EACH STATEMENT EXECUTE FUNCTION partition_after_triggerfunc()
items_after_insert_trigger AFTER INSERT ON items REFERENCING NEW TABLE AS newdata FOR EACH STATEMENT EXECUTE FUNCTION partition_after_triggerfunc()
items_after_update_trigger AFTER DELETE ON items REFERENCING OLD TABLE AS newdata FOR EACH STATEMENT EXECUTE FUNCTION partition_after_triggerfunc()
Reference to the trigger definitions.
Is this redundant? If so, we should consider removing the redundant call from load_partition.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/pypgstac/python/pypgstac/load.py around load_partition and compare its update_partition_stats_q call with the trigger definitions in src/pgstac/sql/003a_items.sql. Trace whether the items-table triggers already perform the same update, then confirm the intended behavior and identify any relevant existing checks before removing a duplicate call. Done means partition statistics are updated once without changing load behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python, sql
- Domain
- database
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100