Skip to content

Exceptionally high number of SQL queries during one hour of the day.

Description

We noticed that every day between 9am (UTC+2) and 10am (UTC+2) the CPU load of our database is exceptionally high. It turns out that during that hour Glitchtip sends the following query multiple times per second.

SELECT "files_fileblob"."id", "files_fileblob"."created", "files_fileblob"."blob", "files_fileblob"."size", "files_fileblob"."checksum" FROM "files_fileblob" WHERE ("files_fileblob"."created" < '2023-03-12 07:35:00.007140+00:00'::timestamptz AND NOT (EXISTS(SELECT 1 AS "a" FROM "files_file" U1 WHERE (U1."created" >= '2023-03-12 07:35:00.007140+00:00'::timestamptz AND U1."blob_id" = ("files_fileblob"."id")) LIMIT 1)) AND NOT (EXISTS(SELECT 1 AS "a" FROM "files_file" U1 INNER JOIN "releases_releasefile" U2 ON (U1."id" = U2."file_id") INNER JOIN "releases_release" U3 ON (U2."release_id" = U3."id") INNER JOIN "releases_release_projects" U4 ON (U3."id" = U4."release_id") INNER JOIN "projects_project" U5 ON (U4."project_id" = U5."id") INNER JOIN "issues_issue" U6 ON (U5."id" = U6."project_id") WHERE (U6."created" >= '2023-03-12 07:35:00.007140+00:00'::timestamptz AND U1."blob_id" = ("files_fileblob"."id")) LIMIT 1)))

Only the timestamps change.

This beavior also happens when no requests are sent to Glitchtip during that time period. Furthremore, the behavior starts at exactly 9am (UTC+2) and stops at exactly 10am (UTC+2), which, to me, looks like as if it is some kind of cron job.

Proposed Solution

I am assuming that this behavior is not intended. Maybe it is a cron job that is accidentally triggered repeatedly during that hour or fails and is retried for that same time period. In any case, it would be good if the number of these queries could be reduced.

Unfortunately, I have no more information about how to reproduce this behavior. If there is anything I can do to gather more information, please let me know.