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.96) (envelope-from ) id 1w9832-001ClZ-1W for pgsql-bugs@arkaria.postgresql.org; Sat, 04 Apr 2026 20:56:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w982z-000Muo-1i for pgsql-bugs@arkaria.postgresql.org; Sat, 04 Apr 2026 20:56:49 +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.96) (envelope-from ) id 1w982z-000Mts-0r for pgsql-bugs@lists.postgresql.org; Sat, 04 Apr 2026 20:56:49 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w982w-00000000cWb-43Bi for pgsql-bugs@lists.postgresql.org; Sat, 04 Apr 2026 20:56:49 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-488a88aeec9so5572245e9.2 for ; Sat, 04 Apr 2026 13:56:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775336205; x=1775941005; 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=xWddgido7exXu9G+2E8l+pIgSi6KoaXskNHhlp3mzSo=; b=qOKcAor9QCuiSe3LmxqlAHlqgzGNHgFAQxhPclK3URUs+KoFyD7nxaSLDBs+WGnZjD iVt1RTrtVGyONGTraCav1ZxCykJw7lXfnNIBDV4Hkyb26TAa2c8xtRmqNEKSFwaxH5h4 BzeJ1k3qqJu32tHnYb0p6Hkl1VPymb3/e4HHZ2KKpe2aMD9v0bql4ZrEZQ0FxV04dp1k 9tSbkCDy6wUEXvxuhhy2P3PTqswVJz5HBxO3kIVGl+XRP6Yc9ewtAcOujqaAyHSUR4UL AC5uIet8Y/Xmk70LhDRW04KoSDxISpEP2UcYsDcbomqSH+gnLY4+vuyonK4Zq3Yt1uG5 qzvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775336205; x=1775941005; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xWddgido7exXu9G+2E8l+pIgSi6KoaXskNHhlp3mzSo=; b=c+r5baFy9AuBgsDY8qDX0dHW2yIoEHAsW+xkMEFsdyDFBLNPdkR7JhBIOC26Mp59c6 oMEqbMQl6im0fiX6m6rmxrgygxIC5dY98mfGprPLSOdTH1Fgn/7ybbqas5jt/n94BIp1 veIBuY8TwO8YdggjEQfPpP3Ndu422HxwNdWRATUDwmBQb/kQPD2VqqHFKe1Br2UmnjUJ zu5TfG6Y2UFPQgDCt2bhm6yOg6OUd1H6Vn7nWM0+1/hA2Fu8klLsuc941a0TwL8qTJN3 7IPlSJBVd34EksSLBr+OTPOUSbEfpXn3jn/AR2g4Fw9Mg7dKZxb7NgkEiia9A1d1TExQ 3+Aw== X-Gm-Message-State: AOJu0YzBFlrgYUpiAjwbwo9w5vMZzfxwNj/nOScPZlXvvRNzefECbhNW nUTnq94so4eOeYYX4U/pI5tZP65bDvhzrURK0XjHARDcjJed+t7tMMjr X-Gm-Gg: AeBDieuuyo8rHsvwVtPv7+t0yiiqcIT83t6ZqyHWUOnrlh+e8D1gTk64qnk5N2xVmKW upcoUGbFD/o8hWiV8CgB6T6EctE0PnFCH4YcWrR1J3TsXr2jWVwwME0FeaHwbB2cAr1yLa1NXsf yXH2UpeFcQRfAsIdSkRj7whZn4SQ2SKtyg+UtKlQQLZK9lnmvLJu03+9zNtaYQjyWMG0IyYcyq/ DfhFrQN8uDf6KJnmuFGV6t1IB3c7jwqVY94z4/mM0Di8WTnhnHsXI7K9LefkOhJ7alP6C4aRdMo bkY8XzdeHqV92sd9oWXSMTxeRf82rZgRXb46aZ+bqBGjAkACZnxGDR0NvRwfQwA1MmY0KElID7S VHPtj57FF33+GcUk99YXnHuafqI4O7o+d/xEUvIY/6jo/KY0quA+25Ae9Kstcz849JSDMD2Ux/h 95fFVO5NreoucoEwQwSaWTRMJSzbj7M7C3+i8G4x6RkELVpFHU/wBj8SUN88BMnJMOgeA72Yk= X-Received: by 2002:a05:600c:4ec7:b0:487:cd8:4c9 with SMTP id 5b1f17b1804b1-488997ed46dmr105537505e9.27.1775336204839; Sat, 04 Apr 2026 13:56:44 -0700 (PDT) Received: from [192.168.0.86] (84.123.226.31.dyn.user.ono.com. [84.123.226.31]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4887e93cf2dsm335439225e9.11.2026.04.04.13.56.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 04 Apr 2026 13:56:44 -0700 (PDT) Message-ID: <7093fa9e-6451-42f7-8956-4f9310545a89@gmail.com> Date: Sat, 4 Apr 2026 22:56:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pg_plan_advice fails when NestLoop outer side is Sort over FunctionScan To: Lukas Fittl Cc: pgsql-bugs , Robert Haas References: <78dd9572-7569-4025-984d-e07d7f381b6e@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 4/4/26 20:52, Lukas Fittl wrote: > Hi Andrei, > it seems to me this is caused by the join analysis tree walker in > pgpa_join.c / pgpa_decompose_join being a bit too specific to what the > core planner will produce, i.e. it only assumes Merge Joins will have > Sort nodes directly underneath them. My initial concern was about the design of the pg_plan_advice extension in general. It seems flawed if it must follow the core plan-building logic. Explore pg_hint_plan - their general concept is just to increase the probability of a template subtree to maximum, not to assume that some constructions are possible or not. > Btw, is your extension available somewhere? That could help verify > that the extension also works as expected with the fix. This is the stage of core patch development. If the community rejects the feature, I will convert it into an extension module (on request). - It is too expensive to support each optimisation when you do it 'just for fun'. -- regards, Andrei Lepikhov, pgEdge