test_analyze
WITH partition_details AS (
SELECT
child.relname AS partition_name,
parent.relname AS parent_name,
nsp.nspname AS schema_name
FROM
pg_inherits i
JOIN
pg_class child ON i.inhrelid = child.oid
JOIN
pg_class parent ON i.inhparent = parent.oid
JOIN
pg_namespace nsp ON child.relnamespace = nsp.oid
WHERE
parent.relname = '<your_parent_table_name>' -- Replace with your parent table name
)
SELECT
pd.schema_name || '.' || pd.partition_name AS partition_table,
st.last_autovacuum,
st.last_autoanalyze,
st.n_dead_tup,
st.n_mod_since_analyze,
st.n_live_tup
FROM
partition_details pd
LEFT JOIN
pg_stat_user_tables st ON pd.partition_name = st.relname
ORDER BY
st.last_autoanalyze NULLS FIRST, -- Prioritize tables never autoanalyzed
st.n_mod_since_analyze DESC; -- Sort by modifications
Comments
Post a Comment