Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1srEiS-00GH2w-Nb for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Sep 2024 10:48:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1srEiQ-009Hcw-Qj for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Sep 2024 10:48:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1srEiQ-009Ha5-Fz for pgsql-hackers@lists.postgresql.org; Thu, 19 Sep 2024 10:48:50 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1srEiJ-001xag-TT for pgsql-hackers@postgresql.org; Thu, 19 Sep 2024 10:48:49 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3787f30d892so426594f8f.0 for ; Thu, 19 Sep 2024 03:48:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726742922; x=1727347722; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=rI4+HzMu1ALoseivBaO5STkAIemzi9cIvh7EXa1RIw0=; b=duwk25JCGe6HuTY8aPlRn6eHvh9ByQXqEsCarMSXHcWRx+vk+3NVQyaOGdtNzh/JSY BmjumXBcy+g4tt60Tt9TePqQMPUxVa6/RH3hK3TdGKn8GVyohr+I85J4wqLp+oscc3ld ByFHtb0hkR3YxVIMfrDmeUdIjr29Gj7wTIqNx62yoILuQuopsqK+5NIlB6xb23au03J5 YZLvNqX8q4rgspgnXc4rCRdRYzG96Y1w1WssG+jgXK18MVmowfXawn4W+xr8ScglFpld x3NuSyu/2/FbQ0+34+Y2UuBCji21lxsF5YMT9A4tIGAIdohvmYGwvStb8tvvGub9EX6p U1Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726742922; x=1727347722; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rI4+HzMu1ALoseivBaO5STkAIemzi9cIvh7EXa1RIw0=; b=o1/shq3eWr91afWEGq4hqX98SpJXAlr7XM4aiDZ5f7DTirJlg4dQl+LpiZBHHjVjtD r1K3osHEYcXZ4hhAdAyI4vEVAu6s1pW4WGH9q9yAIL1XIG1ET8HtI7+LL6SSGchvCZxQ 8BknD+ah9cnk6odEI+AeMepRQEZ2qLfw5Gt8ftKqomPWd//RPyqelOGavG4PHvjif5fI i8SKhwraTUzIDrvpHe9Wy/UvE7PrOV/agtnmh3A5J//74XGTC+i1Cp6+cbvFDSGagIol bvhS2WkXOnupKqGdcAVoP/5hRyGeLV5gliKTEIxqxQIkrnvVviPbXfqRRiifurgEHbal v1Ig== X-Gm-Message-State: AOJu0YxY/vITn0RxW/5OKjGiFB4cpOX1LZ3yiRSZr0pGsPJH8vGinfYt HIWHxFse80XJmjKu4nSV1IBux9BjevZGokRu1OaD03AYrHClXUW0 X-Google-Smtp-Source: AGHT+IEnB2mqNpp76XNQtJi1gdNDG4qRqSOkfnBIRnNeDQ8wu3AfIUM/FFO5KvG8FwwjWX0qVV71qw== X-Received: by 2002:a5d:4f85:0:b0:378:7f15:d51e with SMTP id ffacd0b85a97d-378d62415b4mr12226630f8f.43.1726742922122; Thu, 19 Sep 2024 03:48:42 -0700 (PDT) Received: from [192.168.18.235] ([45.93.57.193]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e754a6f82sm18701175e9.37.2024.09.19.03.48.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Sep 2024 03:48:41 -0700 (PDT) Message-ID: <933001d6-65f7-46b7-9bfe-5f08df58beb7@gmail.com> Date: Thu, 19 Sep 2024 12:48:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Memory consumed by paths during partitionwise join planning To: Ashutosh Bapat Cc: pgsql-hackers , David Rowley References: Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/2/2024 13:51, Ashutosh Bapat wrote: > On Fri, Dec 15, 2023 at 5:22 AM Ashutosh Bapat > wrote: > >>> >>> That looks pretty small considering the benefits. What do you think? >>> >>> [1] https://www.postgresql.org/message-id/CAExHW5stmOUobE55pMt83r8UxvfCph+Pvo5dNpdrVCsBgXEzDQ@mail.gmail.com >> >> If you want to experiment, please use attached patches. There's a fix >> for segfault during initdb in them. The patches are still raw. > > First patch is no longer required. Here's rebased set > > The patches are raw. make check has some crashes that I need to fix. I > am waiting to hear whether this is useful and whether the design is on > the right track. I think this work is promising, especially in the scope of partitioning. I've analysed how it works by basing these patches on the current master. You propose freeing unused paths after the end of the standard path search. In my view, upper paths generally consume less memory than join and scan paths. This is primarily due to the limited options provided by Postgres so far. At the same time, this technique (while highly useful in general) adds fragility and increases complexity: a developer needs to remember to link the path using the pointer in different places of the code. So, maybe go the alternative way? Invent a subquery memory context and store all the path allocations there. It can be freed after setrefs finishes this subquery planning without pulling up this subquery. -- regards, Andrei Lepikhov