mem context is not reset between extended stats - Mailing list pgsql-hackers

From Justin Pryzby
Subject mem context is not reset between extended stats
Date
Msg-id 20210915200928.GP831@telsasoft.com
Whole thread Raw
Responses Re: mem context is not reset between extended stats
List pgsql-hackers
Memory allocation appeared be O(1) WRT the number of statistics objects, which
was not expected to me.  This is true in v13 (and probably back to v10).

It seems to work fine to reset the memory context within the loop, so long as
the statslist is allocated in the parent context.

|DROP TABLE t; CREATE TABLE t AS SELECT i, i+1 AS a, i+2 AS b, i+3 AS c, i+4 AS d, i+5 AS e FROM
generate_series(1,99999)i;

|SELECT format('CREATE STATISTICS sta%s (ndistinct) ON a,(1+b),(2+c),(3+d),(4+e) FROM t', a) FROM
generate_series(1,9)a\gexec
|SET log_statement_stats=on; SET client_min_messages=debug; ANALYZE t;
|=> 369432 kB max resident size

|SELECT format('CREATE STATISTICS sta%s (ndistinct) ON a,b,c,d,e FROM t', a) FROM generate_series(1,33)a\gexec
|SET log_statement_stats=on; SET client_min_messages=debug; ANALYZE t;
|=> 1284368 kB max resident size

Attachment

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Hook for extensible parsing.
Next
From: "Jonah H. Harris"
Date:
Subject: Re: Hook for extensible parsing.