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 1uzDEE-000ngv-Aa for pgsql-performance@arkaria.postgresql.org; Thu, 18 Sep 2025 11:55:10 +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 1uzDEC-00FrBr-W1 for pgsql-performance@arkaria.postgresql.org; Thu, 18 Sep 2025 11:55:08 +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 1uzDEC-00Fr9s-LA for pgsql-performance@lists.postgresql.org; Thu, 18 Sep 2025 11:55:08 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uzDEA-0015FT-1q for pgsql-performance@lists.postgresql.org; Thu, 18 Sep 2025 11:55:07 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-45f29e5e89bso9085335e9.2 for ; Thu, 18 Sep 2025 04:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758196504; x=1758801304; darn=lists.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=wKbX0PnhyBpPmNZCI5WEjeaTfRT5+svxfBA3FjQJA8s=; b=fnf12euk2eQD8sq01ynTBTYqY8Qgl74k7/pX6mqXShdulwxqRkpjnmVtwr3quGCItS XriFjer0T/IYvYqCxF8zgr8owB4p2iHg/6N4m7oxSxCAzjafypK6zWenYiKbOOw7llBt RLSOt0hiDom5XwO15Fu7sySpVNr3BVOCwIHD4hFh0v7rnQ/opAHpaoW2Ui3PriKbopSg KDIS3d9sPzpkxO/qE3an8Q7n5kECYwnKvGpTKBUne8B0I9gtmicZCaFWZ/OCTfTe0O4e 6x4M5dysYqpj64ohMBgVSsBoZ4Lyv+hqlBhabMYhT4I/+YgNpY+Y5cL3CaUTNjZwNcGn 3qeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758196504; x=1758801304; 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=wKbX0PnhyBpPmNZCI5WEjeaTfRT5+svxfBA3FjQJA8s=; b=Fgu4txnVayTYDQZOLv9L6iOXshcN0oMMeb8gRBHsTdlWm4+HOiKN43D4tFaLAc9uan GeGVdL/YU8aZ0IoYUk5P+wm/btBjzoIbkibETKvp/M35TjdG5yuKhUyE68aoz+AA/L6D ni0rAGrNljgJ07N+cIhK+2oLNO9OWARZ5P00C3ndoVMcWYnhDQMGSMO/0fYdGMBbn4XW t9zlKpGoQu9d1QXi0smrwU45CYwaVfzVAcxTEPjZ3DCJ6rnQ3+W8qo1geFpaaIelsPjL QIW6A45HeBzVR0bCmwrmBNek6quaKeqlx6Hz2C54AnzkoXwqruzwIiL1kA8TTh3eJSnA L3Qw== X-Forwarded-Encrypted: i=1; AJvYcCV29q5xdkGFBBAPNiRcamjMXlxHx2KNwkqCFTrNnuVmpTKvVBwaEVCE2S0a8fLXN+z0Mi/bnNJViWEk6d7+ywftVw==@lists.postgresql.org X-Gm-Message-State: AOJu0Yx7R9R3Q+Ivp9H9OP9hUmTSdoe/nthTSTGEaXjw5zlR2gBKdyNE YWKP9V3v+EHXkKjkkzWKfuN6dUGyjYmdBkLsGdmMuOoPczggubJ2/V1X X-Gm-Gg: ASbGncsmS2ZmLkF4c6Qq1tmdtTDTwIBA80mj+TjoBmZt6Q6fe5cqlpWCeGzrAxTnYUT 2ds0uBIwQikqY4HRibZ6JjwmmzaEkgFPkREh0WNXNgS9ug/sxwa+WNy98SEWT0ilJF9ZHBtOPvE n7Osw8UsT9HAy/6YTYyQMCBQQ5jSl+fu67Y+OKVErrVAcIbdUgXn4D8Ml1pijVfrzLOzM9anMUq GsPrpULYMbqXLdRbWXwojK42YB81Png1/DjPbHRf1a1U570HVFJvUN/EqJdbfqh+YC8YoP7Ccas LsGiwz4+E5NdC6NNlEOgFvMsBf1YguuYZIpx7UJNtXVK45Gh0XTEo7dX7PC06SfnXrAwnkHyYhx /AsHuJ3IZh+eMujwFuWj7MFzGgOkzlDXy6mk6WmQjKOwe86ZYj30W X-Google-Smtp-Source: AGHT+IHUQ5awn6TLkVWh/JQ8Ptk7dwmcoyYEU5cVrUThn7NQYyd5if405i5aJL6+tEjATgb+etF+Fg== X-Received: by 2002:a05:600c:198c:b0:450:cabd:b4a9 with SMTP id 5b1f17b1804b1-46206b20089mr47421475e9.29.1758196503912; Thu, 18 Sep 2025 04:55:03 -0700 (PDT) Received: from [192.168.15.124] ([80.251.191.198]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3ee0fbf20b9sm3328673f8f.57.2025.09.18.04.55.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Sep 2025 04:55:03 -0700 (PDT) Message-ID: Date: Thu, 18 Sep 2025 13:55:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Why isn't PG using an index-only scan? To: David Rowley Cc: Jean-Christophe BOGGIO , "pgsql-performance@lists.postgresql.org" References: <8f25c08c-acb2-47ca-b8c1-6664fc31a361@thefreecat.org> <32dc1fe9-175a-4894-b4c4-c6cdc6a76a16@gmail.com> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 18/9/2025 13:35, David Rowley wrote: > On Thu, 18 Sept 2025 at 19:55, Andrei Lepikhov wrote: >> Imagine if we had a hook within the ExecProcNode. In that scenario, we >> could create a trivial extension that would stop the query after, let's >> say, 10 minutes of execution and display the current state. This would >> give us more reliable data on estimation and the state of the plan tree. > > I recall something along those lines existing once in the extension > world. Or maybe just from a previous employer. I don't recall many of > the details. Maybe something like a function you pass an SQL string > and if you cancelled the query it reported the EXPLAIN ANALYZE done so > far. I assume it must have done something like LOG it as it couldn't > have shown the EXPLAIN as query results on cancel. It looks like a makeshift solution. By implementing a callback, we could elevate 'interrupter' to a first-class feature, enabling us to monitor the state of the entire query tree (it is especially cool in EXPLAIN ANALYZE mode when we may be OK with a partial result). What's more interesting if Robert's work on nodes' extensibility successes, it enables modules to save planning decisions in the plan. Thereby, the in-executor callback provides a means to kick off the query planned with incorrect estimations (e.g., too many spilled tuples). Perhaps we should start working on introducing this type of callback/ hook? -- regards, Andrei Lepikhov