But when default_statistics_target is increased to 3000, the session usage is 463mb
IIUC, the analyze process doesn’t consult maintenance_work_mem. It simply creates an array, in memory, to hold the random sample of rows needed for computing the requested statistics.
I skimmed the docs but didn’t get a firm answer beyond the fact that vacuum is an example command that consult maintenance_work_mem and analyze is not mentioned in the same list. I did find:
‘The largest statistics target among the columns being analyzed determines the number of table rows sampled to prepare the statistics. Increasing the target causes a proportional increase in the time and space needed to do ANALYZE
.”