I am facing problem in tracing in what events the selectivity
histogram in pg_statistic is stored/updated.
I went through the code in src/backend/commands/analyze.c and got to
see the code computing the histogram but when I tried to trace the
caller of analyze_rel or compute_index_stats, I find out that only
during Vaccum command, these functions are invoked. I am little
surprised as I did get to see PostgreSQL giving good selectivity
estimations despite me running Vaccuum command even once.
I did try to trace the control flow during table operations
(creation / insertion) but couldn't find any histogram updation
functions being invoked though I did get to know that some functions
related to catalog updations is being invoked.
Can anybody tell me in what all events is the pg_statistic table
exactly updated?