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 1s3FGp-00Ay3X-M8 for pgsql-hackers@arkaria.postgresql.org; Sat, 04 May 2024 13:17:43 +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 1s3FFn-00HZTy-St for pgsql-hackers@arkaria.postgresql.org; Sat, 04 May 2024 13:16:40 +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 1s3FFn-00HZTq-Jc for pgsql-hackers@lists.postgresql.org; Sat, 04 May 2024 13:16:40 +0000 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s3FFh-001W4a-Sf for pgsql-hackers@lists.postgresql.org; Sat, 04 May 2024 13:16:39 +0000 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2df9af57b5eso6740401fa.2 for ; Sat, 04 May 2024 06:16:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714828592; x=1715433392; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ObQWWw1sn76WnH+zXXeB9147x+Syi97G3vVyM0yC754=; b=NfcTKJ0VBnmViJtF/0kmsUJWioct4BPDfmiN2WB6UFQm+JrFD4o/Wslu0PUavnJy2w Xl57jYfYduZ04BfQVBs/aCOZP2GAVqwY3/E55dF9oYLPLsXIlxc18HvE9jGOMjzCukEC jAKui47dePizIG0WDWOlqEGjj4m7lWM1yZz2p99/R3+m7nhSJFIFGbN0cJOyB2x9eflF nL8hI5x2YoCxABo9YETFLGeUWVefLHvM12ZqTNB1vrxYaHLSsW0zeu5puozfMIn5jDvn N42Wq3PI7CuF9Oq5ajFNxaBw3YL4isByNC7dj3seP4TI3P2MOqK0pWmSbIq0MP4m5HHy fMhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714828592; x=1715433392; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ObQWWw1sn76WnH+zXXeB9147x+Syi97G3vVyM0yC754=; b=mX8OvB13B4wJJG+eLyol0jGitb4pUjLtcme1L0/HGzF2m424X2I/3BcroY8/QjuCLK NmgdFjILA9VOlh66zo8mSWWK2/uLKCT2UBXRHGeymONdVhqSQ2/4nXd4I75HkCdmnF/v 1e53TSbDZ6hoY8RaUMtBPcQAU3e5DIbpTGToJp4WO6C0r7KgRKpcj+qhLiWNhzeyRxfu ilInEr2OT8xPF6pXSoDxw2v6ldWBvLfs9z8K9AYpab92cBYk+htQWrymiDToBsO15pTF MwYMS2fTR/yMa7GUQ/B3hJNRcF5kOocqz02gi2FCfEn5mENXBhx61SeN9YR3PgMoqrcg srmA== X-Forwarded-Encrypted: i=1; AJvYcCXHwMqV+EQBTRBkRsgQV0l3cUrL7dUTfiCHX32A3APiTI2qOAF73iEEUa47n2xk+yfDLDY2b7tBfiH+E5v1Cs8TFbRgNXTc9h2pljnjiF9qdT9s X-Gm-Message-State: AOJu0YwlYUbcZ7gLLNnFpWQlVGg6RyYe3BkHmaahJOCkprKMyhqvBYBV OYalgJjT5jq5QopIo8sd5O3gdvjh04V/5mSYyq9w8A4OSzb2+EJtbDrmqH/fLU7+E4RQRKeofY2 t4/BbxUJRaWWgqLf112a4VgpdZIc= X-Google-Smtp-Source: AGHT+IESQwAHUPZjxhhc5Mg21amaeuRN6St/vdKR7zKclRxvTSBQqK9oDyunyy+GBh0ilmzhq2yyRCVJj4NwuSYvwJA= X-Received: by 2002:ac2:4d19:0:b0:51d:9ef1:7c62 with SMTP id r25-20020ac24d19000000b0051d9ef17c62mr4505685lfi.6.1714828591811; Sat, 04 May 2024 06:16:31 -0700 (PDT) MIME-Version: 1.0 References: <29821.1572706653@sss.pgh.pa.us> In-Reply-To: From: David Rowley Date: Sun, 5 May 2024 01:16:19 +1200 Message-ID: Subject: Re: On disable_cost To: Robert Haas Cc: Tom Lane , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 4 May 2024 at 08:34, Robert Haas wrote: > Another idea is to remove the ERROR mentioned above from > set_cheapest() and just allow planning to continue even if some > relations end up with no paths. (This would necessitate finding and > fixing any code that could be confused by a pathless relation.) Then, > if you get to the top of the plan tree and you have no paths there, > redo the join search discarding the constraints (or maybe just some of > the constraints, e.g. allow sequential scans and nested loops, or > something). I don't think you'd need to wait longer than where we do set_cheapest and find no paths to find out that there's going to be a problem. I don't think redoing planning is going to be easy or even useful. I mean what do you change when you replan? You can't just do enable_seqscan and enable_nestloop as if there's no index to provide sorted input and the plan requires some sort, then you still can't produce a plan. Adding enable_sort to the list does not give me much confidence we'll never fail to produce a plan either. It just seems impossible to know which of the disabled ones caused the RelOptInfo to have no paths. Also, you might end up enabling one that caused the planner to do something different than it would do today. For example, a Path that today incurs 2x disable_cost vs a Path that only receives 1x disable_cost might do something different if you just went and enabled a bunch of enable* GUCs before replanning. > Now, I suppose it might be that even if we can't remove disable_cost, > something along these lines is still worth doing, just to save CPU > cycles. You could for example try planning with only non-disabled > stuff and then do it over again with everything if that doesn't work > out, still keeping disable_cost around so that you avoid disabled > nodes where you can. But I'm kind of hoping that I'm missing something > and there's some approach that could both kill disable_cost and save > some cycles at the same time. If (any of) you have an idea, I'd love > to hear it! I think the int Path.disabledness idea is worth coding up to try it. I imagine that a Path will incur the maximum of its subpath's disabledness's then add_path() just needs to prefer lower-valued disabledness Paths. That doesn't get you the benefits of fewer CPU cycles, but where did that come from as a motive to change this? There's no shortage of other ways to make the planner faster if that's an issue. David