Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mSUjI-0000rM-Mu for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Sep 2021 01:37:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mSUjH-0000gn-Lo for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Sep 2021 01:37:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mSUjH-0000gf-9X for pgsql-hackers@lists.postgresql.org; Tue, 21 Sep 2021 01:37:51 +0000 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mSUjE-0002dh-IA for pgsql-hackers@postgresql.org; Tue, 21 Sep 2021 01:37:50 +0000 Received: by mail-io1-xd30.google.com with SMTP id z6so18029320iof.5 for ; Mon, 20 Sep 2021 18:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=URbzGQ8wVjLvxsbh3z6JUGzu3LZi33tRvWx8gJjQqNI=; b=7zVW+cAhsONOVIc0j1F8LfZQFwqYWEetZaU+zp+P7IEWW9GHZkMj3CyzhF70h5sPD8 GU6lXTsoPIThl/SOl/9LPyAzW7FFFd0Veh40lLzbIO8ZtUlqCAEVG3SqFRSsbGysfQ3u Y94nnB82gUjxwtzBvXp+nStoZ5D7yGxZHvF5rp8lp/MvvejWmbKbhA7aNb+e2qyOtfFm mkKAKqyaLnJ+UaJKmweSwcr1VXUWoMYZEv4uhQEKlPSYoYl921ssKZ91MCdtVaDpAh+E U8SJGAaTrz/u1M7KZd0gRHKJPeKbvkYnKQDmid3Szqr9QX/kt3SdmPeBCqMoGNUcgHu4 2IjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=URbzGQ8wVjLvxsbh3z6JUGzu3LZi33tRvWx8gJjQqNI=; b=HZTTnyYKZYAQNq1yIQEGTuNUeRTUPLPh33ZWUusKNBPG3k0MGLl2cjrkRhkAO3S1XU ckYxtw52UcUfbDLpDtVtRz/jZEcQz8JEaRDrR1zgbC0Lt927UFoYJADoyanUCAZglV3+ cBrkz+En+bYXCsqUdwWaj392zKBdXXwVC/Ko+32J/yROwuVV2cJbDmmC1x1tw8Rc4EPV zTNeQnoY5SC8LBHqicm9XAR08iz3dLA1KMqv5JIgvquSl0ysw37NZoPSTzsYMLZp91uw z/PAyEHiW3S7r34nWNehn3xdYzbzi0stggndAFml5sYH44rSUjH8u94hb2obc4oVgsEp euSA== X-Gm-Message-State: AOAM530d8cG/dpBu0Bq6o2KLZ3G0B+izhBtc7bwDxSYMJN/JrSrYflXa i4gEVDla2nw1eB1nrER4z9RUoUs1PfKq8A== X-Google-Smtp-Source: ABdhPJx6JRoezhZvsdzsmf13Gm4xOfBic7Tc4b8LVdetuLcawi3wXT8lQXCVza/65G2BerYh71AaQQ== X-Received: by 2002:a5d:8894:: with SMTP id d20mr20370851ioo.4.1632188267575; Mon, 20 Sep 2021 18:37:47 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id k16sm603172ilr.60.2021.09.20.18.37.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Sep 2021 18:37:47 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 7181B800C0B; Mon, 20 Sep 2021 20:37:45 -0500 (CDT) Date: Mon, 20 Sep 2021 20:37:45 -0500 From: Justin Pryzby To: Tomas Vondra Cc: pgsql-hackers@postgresql.org Subject: Re: mem context is not reset between extended stats Message-ID: <20210921013745.GM831@telsasoft.com> References: <20210915200928.GP831@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Sep 21, 2021 at 02:15:45AM +0200, Tomas Vondra wrote: > On 9/15/21 10:09 PM, Justin Pryzby wrote: > > 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). Of course I meant to say that it's O(N) and not O(1) :) > In principle we don't expect too many extended statistics on a single table, Yes, but note that expression statistics make it more reasonable to have multiple extended stats objects. I noticed this while testing a patch to build (I think) 7 stats objects on each of our current month's partitions. autovacuum was repeatedly killed on this vm after using using 2+GB RAM, probably in part because there were multiple autovacuum workers handling the most recent batch of inserted tables. First, I tried to determine what specifically was leaking so badly, and eventually converged to this patch. Maybe there's additional subcontexts which would be useful, but the minimum is to reset between objects. > These issues exist pretty much since PG10, which is where extended stats > were introduced, so we'll have to backpatch it. But there's no rush and I > don't want to interfere with rc1 at the moment. Ack that. It'd be *nice* if if the fix were included in v14.0, but I don't know the rules about what can change after rc1. > Attached are two patches - 0001 is your patch (seems fine, but I looked only > very briefly) and 0002 is the context reset I proposed. I noticed there seems to be a 3rd patch available, which might either be junk for testing or a cool new feature I'll hear about later ;) > From 204f4602b218ec13ac1e3fa501a7f94adc8a4ea1 Mon Sep 17 00:00:00 2001 > From: Tomas Vondra > Date: Tue, 21 Sep 2021 01:14:11 +0200 > Subject: [PATCH 1/3] reset context cheers, -- Justin