On 4 April 2014 16:01, Andres Freund <andres@2ndquadrant.com> wrote:
>> + const char *stage_commands[] = {
>> + "SET default_statistics_target=1; SET vacuum_cost_delay=0;",
>> + "SET default_statistics_target=10; RESET vacuum_cost_delay;",
>> + "RESET default_statistics_target;"
> This whole thing won't work for relations with per-column statistics
> targets btw...
Yes, agreed. Plus I would note that this makes no difference at all
for very small tables since the sample will be big enough even with
stats_target=1.
ISTM that this is the way ANALYZE should work when run on a table that
has never been analysed before. Let's just do this logic within
ANALYZE and be done.
Suggest logic if not ANALYZEd before && table is not small && stats_target is
default then AnalyzeInStages()
otherwise just do one ANALYZE pass
-- Simon Riggs http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services