Files
threshold/internal
Timothy Messier 33037b4887 perf(db): Use statement trigger for marking deleted sessions
When sessions are deleted, a trigger is used to insert records into the
session_deleted table. This table is utilized by the sessions list
endpoint when using a refresh token to inform a client of the sessions
that have been deleted since the last request. We delete sessions in
bulk via a controller job to delete sessions that have been terminated
over an hour ago, which results in the trigger running a large number of
separate insert statements while processing the delete statement.

This changes the trigger to run once for the delete statement, instead
of for each row, resulting in a single bulk insert statement to the
session_deleted table.

This new trigger function also avoids the use of `on conflict`. When
testing this function, while the single statement was still faster than
running multiple inserts, the `on conflict` still added significant
overhead, even when there were no conflicts. It should be safe to
perform the insert without the `on conflict`, since the same ID should
never be deleted more than once if it is successfully deleted.

(cherry picked from commit 3569b36c6eb2bee7a4e36e7584fcc6bbf1124f95)
2024-09-24 14:18:54 +00:00
..
2024-09-19 12:30:10 -04:00
2024-09-09 09:22:34 -07:00
2023-08-11 10:31:53 -07:00
2024-02-16 08:30:16 -05:00
2024-01-25 09:43:40 -08:00
2023-08-11 10:31:53 -07:00