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 1uGhHT-005zO3-U1 for pgsql-performance@arkaria.postgresql.org; Sun, 18 May 2025 16:54:32 +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 1uGhHT-00AuEK-02 for pgsql-performance@arkaria.postgresql.org; Sun, 18 May 2025 16:54:31 +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 1uGhHS-00AuEB-Lu for pgsql-performance@lists.postgresql.org; Sun, 18 May 2025 16:54:30 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uGhHP-002QDR-1J for pgsql-performance@lists.postgresql.org; Sun, 18 May 2025 16:54:29 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-442ea341570so22614885e9.1 for ; Sun, 18 May 2025 09:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747587266; x=1748192066; 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=irMMilEYYKw96Ksigmx9gYzXsS/pN5WNM8H9BrfYvJA=; b=heL0ypx4R2zFvL678UyDccsa1prBMOZjqN6naqrdT1jjQszYFdqY5tmrxAhsB5iuWt L3FC41+9fAkmUaM0XTfbwt2Ays4uunm6wgn50lEv7FiHR/yslBt6vN1AhW8WTg42iJAa Y4qnaq4oW5JrZIYxEX3amIL0WnQuSVvCrAuYOTwsqjOuZHCGWYvPAR9lM0gi+8kvNxOf LvVAcFj/3aFWQcEtoNo1Ec7ggqPX27s5Q8rJaMWMqEMH5th7/q/AmbhqSwGAWTidaoCG 574zw8BEvkxaJjw5O9vSacqlBe8GPPg0KrH+ta3OfbIneGV6W0tu2D5VeUkz4EV9X6+D vj9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747587266; x=1748192066; 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=irMMilEYYKw96Ksigmx9gYzXsS/pN5WNM8H9BrfYvJA=; b=h9NvFRQQu6IKQ7tVGCy/Gv+JOjfveiJhsCuMQ66QmiTuRqfUfwJ7UF0t38cstspjdd rRREoosjeIlV8S0H7fNs1636g/yqv3980V0NlJk6Sbd55Aik7oo79ISmvl4d3Sw5s+Pa /i91sTXi4rdLYHJqsM8+Wkqcyje//Gg0bKVu9iBSzq2NI9aA8edgVkx3TEdrtyaxSMqO IvYZrBdwFLZimvnDIs2HLtxoLvz4HLxDnqjgf2p98sh3e6zAZMPy3/klD5gx4xroKyxP DPGKld4RkCem39G5niM2ed6GDegQHzCsaR2jbu114O2pLla/nzynr92vdabJDii7yGkO 1Hyw== X-Gm-Message-State: AOJu0YxCqOfyN5bgRkYQItO/iYPFEwTBeb0BqAYwxvmjZd6dP9qPgGib jZtwYz9EB2M3H8rr79Uj5CFUZNG2lXGixE4YHQ8PBu+GKQXx/ofUVYMs X-Gm-Gg: ASbGncuUD1qbGGfwO5bRbO7f6l027zzYC4q4XNL9L+cRAK+i+mhv+/O3XmoJNNUwKIS XyaCHcupWPKf8MVjjHKi1+0Uv7hZLdbboVXht3WuE6y76AWoKBV1x1tcv6qdMOaEgm5HMoBEGNc 57h/ezSlkgqqPcKeCdrp1/vuT55XBCrVP0xq44wfcryj2tmyvOen3fUB0ZYbG17rFl93f8vWVFr DA0SfLOjvopHPTzw8Dslo6JHmXOtLWTGsoR/bdekBxOJP90RIYDwIxwCuOQOQD7XJCmi/hSjWwu IJbv1jMjydhAxg5rJaPzTDDh/eS9T8bMSdvJefFOJj8yNmFZR2QLNqHLw86uOunmA7fSOTLJoai 7nYCU6OsJTA== X-Google-Smtp-Source: AGHT+IGfncP8IztpyGk8KbJqSKh+e1NCNI/JQsFnD+VSaEKcfwyKV/dE0f1bdfzRTzttBLKOcReBQw== X-Received: by 2002:a05:600c:1e1c:b0:442:f482:c42d with SMTP id 5b1f17b1804b1-442fefef17emr85452385e9.9.1747587265341; Sun, 18 May 2025 09:54:25 -0700 (PDT) Received: from [192.168.0.89] (84.123.234.224.dyn.user.ono.com. [84.123.234.224]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-442f3369293sm185494055e9.6.2025.05.18.09.54.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 18 May 2025 09:54:24 -0700 (PDT) Message-ID: <34dbb623-e7ef-403f-b7b1-082c856f897e@gmail.com> Date: Sun, 18 May 2025 18:54:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: inefficient/wrong plan cache mode selection for queries with partitioned tables (postgresql 17) To: Maxim Boguk Cc: pgsql-performance@lists.postgresql.org References: <8480be46-6e2a-4b12-9f80-78ba3db79dfb@gmail.com> Content-Language: en-AU 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 5/12/25 16:04, Maxim Boguk wrote: > On Mon, May 12, 2025 at 4:48 PM Andrei Lepikhov If I'm not mistaken, it will work with all PG versions that are > currently in support. What do you think? > > > Such extension would be very useful (and in general - the solution based > on the actual execution data - seems more stable/predictable than the > plan cost based selection which is currently used by postgresql). I've written a sketch of such an extension; see [1]. A trivial strategy is implemented to force prepared statements to use a generic plan if the planning time exceeds the maximum execution time. It is just an example - it is written in plpgsql, and you can implement alternative strategies independently. I would be happy if it covered your use case. Any feedback is welcome. [1] https://github.com/danolivo/pg_mentor/tree/main -- regards, Andrei Lepikhov