DEV Community

dimas
dimas

Posted on

Find high dead_tuples

Find High Dead_tuple for vacuum

SELECT
    schemaname,
    relname,
    n_dead_tup AS dead_tuples,
    last_vacuum,
    last_autovacuum,
    last_analyze,
    last_autoanalyze
FROM
    pg_stat_all_tables
WHERE
    n_dead_tup > 1000  
    OR (last_vacuum IS NULL AND last_autovacuum IS NULL)
    OR last_autovacuum < now() - interval '1 day' 
ORDER BY
    n_dead_tup DESC;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay