Re: Optional skipping of unchanged relations during ANALYZE? - Mailing list pgsql-hackers

From VASUKI M
Subject Re: Optional skipping of unchanged relations during ANALYZE?
Date
Msg-id CAE2r8H5Gsfs4REdo=Phj2GUv18Q5fsy-CBq0jbXyjrK1V-P5ag@mail.gmail.com
Whole thread Raw
In response to Re: Optional skipping of unchanged relations during ANALYZE?  (Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>)
Responses Re: Optional skipping of unchanged relations during ANALYZE?
List pgsql-hackers
Hi Hackers,

As discussed in the recent thread, I’m sharing an initial v1 patch
introducing an opt-in SMART mode for ANALYZE.

When ANALYZE (SMART) is specified, relations that have not been modified
since their last analyze are skipped, based on existing pg_stat counters
(n_mod_since_analyze = 0). Relations without existing statistics are
still analyzed normally. The default ANALYZE behavior remains unchanged.

The primary goal of this patch is to reduce unnecessary work when
running ANALYZE over many mostly-static tables, while keeping the
behavior strictly opt-in.

Scope of this v1 patch:
- Uses existing pg_stat statistics only
- Does not skip relations that were never analyzed before
- Includes regression tests demonstrating that only modified tables are re-analyzed
- Partitioned tables, inheritance, foreign tables,extended statistics and other edge cases   are intentionally not handled yet; I plan to look into those in follow-up work based on feedback

Example usage / how to observe behavior:

    SET client_min_messages = debug1;

    ANALYZE (SMART);
    ANALYZE (SMART, VERBOSE);

    ANALYZE (SMART) table1;
    ANALYZE (SMART) table1, table2;
    VACUUM(SMART);


Thanks for your time and review.

Best regards,
Vasuki M
C-DAC,Chennai
Attachment

pgsql-hackers by date:

Previous
From: Akshay Joshi
Date:
Subject: Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement
Next
From: Christoph Berg
Date:
Subject: Re: Optional skipping of unchanged relations during ANALYZE?