Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate redundant partition stats update #283

Open
drnextgis opened this issue Jun 29, 2024 · 1 comment
Open

Eliminate redundant partition stats update #283

drnextgis opened this issue Jun 29, 2024 · 1 comment

Comments

@drnextgis
Copy link
Collaborator

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.

@drnextgis
Copy link
Collaborator Author

There is a difference between these two invocations: in one case, the function is called with istrigger set to False, and in the other, it is set to True. This affects the execution of update_partition_stats because certain parts of the function are skipped when istrigger is True, while the rest of the function still runs. Therefore, the point that the same piece of code executes twice remains valid.

@bitner, could you please elaborate on why the "Modifying Constraints" part is skipped when update_partition_stats is called with istrigger set to True?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant