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 1tbVI5-00BAmi-MH for pgsql-hackers@arkaria.postgresql.org; Sat, 25 Jan 2025 01:48:54 +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 1tbVI3-00103X-Vp for pgsql-hackers@arkaria.postgresql.org; Sat, 25 Jan 2025 01:48:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tbVI3-00103P-Hd for pgsql-hackers@lists.postgresql.org; Sat, 25 Jan 2025 01:48:51 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tbVHz-001MkE-2X for pgsql-hackers@lists.postgresql.org; Sat, 25 Jan 2025 01:48:50 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-216426b0865so45998875ad.0 for ; Fri, 24 Jan 2025 17:48:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1737769726; x=1738374526; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=/tB9gaEr5BMisJe9KvpNrv3Xcxcop9SjDArMtBdFWxQ=; b=m2OOn6/bmJlMTs2GHh1qpWmE1jjfo4rz6461pl1sDW82sRkDBkSTn+QqIxwEyxzRIN B50jT17r2pCH3LhW+NpoUjBP+YbnmhBRInl6mltwNyu/5o1HVqZO8mq/B93BhSkJJQU1 E5hrM7YMfNRHWP69T4SgNnp+IabkxzbIRZsMermaUhf9Ig2YqDSZySoHQuLSEx+akFMn E41QbMjcQm+0s+P10o7u1wc5LXeHHhqq1YgxNeN5KrBEECKp5lLitFEB2ucFy4XsbZ7B K3WvavGAUmYeV7LlykudBL94+8Rz2WUIbcqc4MT5O2+jSoHXJEsSNEFu79yDDD3lVHP4 lAFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737769726; x=1738374526; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=/tB9gaEr5BMisJe9KvpNrv3Xcxcop9SjDArMtBdFWxQ=; b=hFcmB/iYBxgMoEFbxvta1+AJ2PegKBARO/gPHqc7rvRFfjhrCtoJvrzCQZPy0GFRyA awjSXsYht+B7iPguJWNZ4oAqFufouRV5RZnpp5eqwkAUB8Y9hZ71vaRhzQnGBU9IIjYZ QOMzYZYqMfCfSbSLvevexViyR3TgNuiPDojRUwOyYx9LlvuU9CgQ419H7o5Cl+O7Bcll dGY8oW5ULnAQMDNTVeYKartREZNphafWi9u/2LCG8iNuzGSqh2BjE1NhFtcv3l+b9pBf BhDFDl4zTVMpI0mu30Y3CFnfLVb4hB+ukoKQadQ6JOxsBM/OI196PD0LUm1bmtwHPj3J 6Cig== X-Gm-Message-State: AOJu0Ywo4DxwVSxSzDpwDiTmp0w4QGysmlA4OW/AFZ6KzSSROf2kn97A FbUQzy2uHBm3qd5EIYcxjSuw4kRj8czfH8WgfnAeByDlQzpFa6Nsf51SoSUEiQ== X-Gm-Gg: ASbGnctDK04rMkbq79D9O8bq63j9H1eQ3VFECDMxCCcW2DlhZ1KDmBY9bo844+NclI5 AWZ96UdOaSYWIvxibxdi+RrExYko9AiXZDDYg7hd9KAKdhKEBovULHtXCFz0M8Sd65QV02o3oSU zjd7YkAovkLSMCAujvp0I7MKAi7fSKN0UtE1MLDfa3Qnu9ZbMsHnrsAPIIhji6NgCwD34AksWaP xuXSWk6D4EHg7qd5ygstx0+0b+TVClv1rQ8cv/ZMC/oaAvTozezKSvv4bKNpy/KxxVxad5IHCf8 U8K8vI5py8IM6tEwVgF2eWpXbqm9n4jT2vNtUbvUj383DjU= X-Google-Smtp-Source: AGHT+IGbE2ep1T+6sikABZN+eNQ1GKhl1eHWSfNcDPBh1bZXFBecVbHW6ixylkDNFlSc5YQwo6jUbg== X-Received: by 2002:a17:902:f791:b0:216:5294:619b with SMTP id d9443c01a7336-21c355f6c65mr444744635ad.47.1737769725996; Fri, 24 Jan 2025 17:48:45 -0800 (PST) Received: from jeff-laptop.lan (c-76-102-242-158.hsd1.ca.comcast.net. [76.102.242.158]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21da424f61fsm22511985ad.237.2025.01.24.17.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 17:48:45 -0800 (PST) Message-ID: <6b134f12c727fdb3a03849deab585dea0dfb30aa.camel@j-davis.com> Subject: Re: Proposal: "query_work_mem" GUC, to distribute working memory to the query's individual operators From: Jeff Davis To: James Hunter Cc: "pgsql-hackers@lists.postgresql.org" Date: Fri, 24 Jan 2025 17:48:44 -0800 In-Reply-To: References: <0beedccb92ba5a1db386bd09b44e15b20c1ac1fc.camel@j-davis.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 2025-01-24 at 17:04 -0800, James Hunter wrote: > Generating "high memory" vs. "low memory" paths would be tricky, > because the definition of "high" vs. "low" depends on the entire path > tree, not just on a single path node. So I think it would quickly > lead > to a state-space explosion, as you mention. At first, it appears to lead to an explosion, but there are a lot of ways to prune early. Many operators, like an index scan, don't even need to track memory, so they'd just have the one path. Other operators can just generate a low memory path because estimates show that it's unlikely to need more than that. And if there's a blocking operator, then that resets the memory requirement, pruning the space further. And I assume you are talking about analytic queries with reasonably large values of work_mem anyway. That justifies a bit more planning time -- no need to generate extra paths for cheap queries. Maybe my idea doesn't work out, but I think it's too early to dismiss it. Regards, Jeff Davis