France-ioi / AlgoreaBackend

Backend for the new Algorea platform
MIT License
1 stars 2 forks source link

Potential performance issues in other `items_items` triggers #1083

Open GeoffreyHuck opened 2 months ago

GeoffreyHuck commented 2 months ago

Where the issue was fixed

We fixed an issue when a relation between items is deleted in this PR: https://github.com/France-ioi/AlgoreaBackend/pull/1066

The problem was that more than 50k entries were added in results_propagate - in the before_delete_items_items trigger - when a relation in items_items was deleted (all the results with item_id=OLD.parent_item_id. This made the updateItem service timeout.

Other cases with the same issue that were not fixed

We have other triggers that add rows into results_propagate, like the before_delete_items_items used to:

How to fix

We can use the same fix as before_delete_items_items.

Additional possible problems in triggers

Other problems might arrive from triggers. Here's a list with a rough explanation of the number of inserts that happens. I can be wrong analyzing the queries since I never touched those parts.

Into results_propagate:

Into permissions_propagate: