We are using external database and we are having an issue where we are hitting higher cpu. We see below query is executing every 2 secs. Why is this query running this frequent and how can we stop this query from executing if it is not needed
SELECT
c.relname,
CASE
WHEN c.relispartition THEN 'p'
WHEN c.relkind IN ('m', 'v') THEN 'v'
ELSE 't'
END,
obj_description(c.oid, 'pg_class')
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
AND pg_catalog.pg_table_is_visible(c.oid)
What version of Postgres are you using? What version of AWX are you using? Did this start happening after an upgrade? If so, what version were you using before you noticed high CPU usage on the PG side? Has the high CPU persisted, or has it relaxed since? Upgrading AWX does perform some initialization/migration steps on the DB, but that only occurs once each upgrade.
Unfortunately, I don’t know enough about the backend of AWX to really help much further, but those who do would probably like a lot more information than you initially provided.
For each django db connection we set application_name to be the AWX service + the process ID. This is helpful to trace back which process is using which query.
can you run SELECT application_name, query FROM pg_stat_activity; until you find the problematic query and post the results here?
Below is an example set of results
awx-manage dbshell
awx=> SELECT application_name, query FROM pg_stat_activity;