Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mN8rk-0003JT-A1 for pgsql-general@arkaria.postgresql.org; Mon, 06 Sep 2021 07:16:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mN8rj-0004uE-A3 for pgsql-general@arkaria.postgresql.org; Mon, 06 Sep 2021 07:16:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mN8rj-0004u2-1U for pgsql-general@lists.postgresql.org; Mon, 06 Sep 2021 07:16:27 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mN8rc-0007UP-Mq for pgsql-general@lists.postgresql.org; Mon, 06 Sep 2021 07:16:26 +0000 Received: by mail-wm1-x331.google.com with SMTP id 79-20020a1c0452000000b002e6cf79e572so4197977wme.1 for ; Mon, 06 Sep 2021 00:16:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=j9YxpY09O0VyoY5t7B0n715H13s9FJlr81542UE3Iho=; b=ylmormuqtjSoRXVT6wudUeTRagTBFAupGioQIuZyGNdHjbtAB1m5Z0cDr1fOnuOHge JrrPUnlcRI4CIdcqbmDf1FqhwE3GLK5RbQ0IZNJc0/3bz+KipARTXV/NZaEZnVPf1/m5 6XlyUhwsHwDAEaL74B/RAZEascXzu7RjF30hAkPXQdGgEr7t8pFeNa48YetHCqP7aBDs ltXNfhw9LnIp2TSmtWILYWvl0vXX+MLzbnLZSzJrqmISrijot8boRIT+czyJIHNEnMxT qIUdY5wubh/yzZme57Xt8sNMUPXWFiLKs/gaCQNRQJ5rzvTv81MvHWJyxMAxRTCcO9y6 eemg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=j9YxpY09O0VyoY5t7B0n715H13s9FJlr81542UE3Iho=; b=mtMg+4PjTRyCQ3oSIt1XJyHhznL1TOXXJ/PU8/ZvV3Vh8r6qtzz3ohcZngyx4sZbTv soCtT1pH6cNVo1YU8YU7hf+xvn4PBy/K7dY4xKHz7kI6g0/g/hqewyM0quY3B4z6JXNB RXMDraTzAke7PBq68KYJwv39O36pwqmGjKcC/68Gk6c8Rv6/3BUkdr9CL4E+ySgdBQDK QLDXaH8HIZ9VG9H3IUwT/vPzrEgpIW0lofKBr71LiwVvfIwcDxeXDoM5fWBMatpbGQVV AN8JZb0zEM1GKN7pqGyOtTq6ozZ8D5PHLBi7YLh8RBZ+YnbbMpGHiA2aXgMDDQ4YN6Oe f1eQ== X-Gm-Message-State: AOAM531Dm9kKLPnmMoYndLSZBw2nNd8ONcAQD6z8QWElTrR8AU4fUQdY 8YUXj3nyxBG6msgzlxd4ibPIjA== X-Google-Smtp-Source: ABdhPJymJOp5spqccZM9mvk4NudZteYPUCWekh1CwlXAGGIW1cTQ1gK+yIseauNZZ75LpsTyQ6OxuA== X-Received: by 2002:a1c:2bc6:: with SMTP id r189mr9931652wmr.183.1630912579275; Mon, 06 Sep 2021 00:16:19 -0700 (PDT) Received: from localhost.localdomain (dynamic-e2fcj9ch68fod91kp-pd01.res.v6.highway.a1.net. [2001:871:5c:9bf4:adfc:f0e1:43e0:ed39]) by smtp.gmail.com with ESMTPSA id x11sm7043849wro.83.2021.09.06.00.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Sep 2021 00:16:19 -0700 (PDT) Message-ID: Subject: Re: How to observe plan_cache_mode transition from custom to generic plan? From: Laurenz Albe To: Mladen Gogala , pgsql-general@lists.postgresql.org Date: Mon, 06 Sep 2021 09:16:18 +0200 In-Reply-To: <052c4c64-cd0e-9e14-ae9d-ca0e553a3bbf@gmail.com> References: <0f9c9510-f4f3-0388-b382-36063f0d4e36@gmail.com> <3968ca671180b32b8199b2a1c1fbf9a43fa14d60.camel@cybertec.at> <052c4c64-cd0e-9e14-ae9d-ca0e553a3bbf@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2021-09-06 at 03:07 -0400, Mladen Gogala wrote: > > On 9/6/21 2:26 AM, Laurenz Albe wrote: > > "Bind variables" just being an Oraclism for parameters, it is*not*  a > > mistake to use them in PostgreSQL. > > Actually, it is a mistake because they don't give you any performance > benefit and can potentially worsen the performance. There is no cursor > sharing and generic plans can be much worse than "custom" plans, > generated with the actual values. The only reason for using bind > variables/parameters is to protect yourself from SQL injection. I disagree. There is defnitely a performance benefit in not generating a plan for each execution, even if plans are only cached per session. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com