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 1mN8iz-000322-Iz for pgsql-general@arkaria.postgresql.org; Mon, 06 Sep 2021 07:07:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mN8ix-0001Fr-Q8 for pgsql-general@arkaria.postgresql.org; Mon, 06 Sep 2021 07:07:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mN8ix-0001Fg-F5 for pgsql-general@lists.postgresql.org; Mon, 06 Sep 2021 07:07:23 +0000 Received: from mail-qv1-xf31.google.com ([2607:f8b0:4864:20::f31]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mN8iu-0000Sn-6W for pgsql-general@lists.postgresql.org; Mon, 06 Sep 2021 07:07:22 +0000 Received: by mail-qv1-xf31.google.com with SMTP id e18so3509178qvo.1 for ; Mon, 06 Sep 2021 00:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=Wq9RAtogO5nBD9Dvt0qVRl4h/phsuBLsWsVyCp/D8AQ=; b=m9WMmG1yuE13NjwNwJtZrm4u6A5jilhi17JDlOX2Tzx3UYhx8GMsN6jHhdkk3Xp5Pf od82Agc3WfNef7onh/4/HaZiMk/2z2cdSKKirZWj3r1n/RA3S92nWbTmFV5zA7fPnWLL dWzkkWqJetl0UmIJ4RyWMtcun1LwMyXPLsS6Ca6Viyk2SR5B14Wy7as8EE3uv9Z11SJ3 p+kpMT9/5svJUb6oNj0HNeCk66LOsN37Mz0xBlkmZTAb/7/hRyeUfJQAWUs/ybSCWfcH p6GN3AMnvc725Yw2aFPE0bTKVLbMSs27f5Vs3W52cRb8g7cADyw7jzrv3qTzWR5IZvc/ fuHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=Wq9RAtogO5nBD9Dvt0qVRl4h/phsuBLsWsVyCp/D8AQ=; b=Ulw52+DOj6xuJqApxw6pOdSPGWT4+vdp+SeLrU5fvK6IHFsD3bCkIN4kFTRFgNDLzz SsEJVcyNhvZWDNjn620SnT9WCAA2xTM3YfG8QPpV5ye8HD6JFve+L6ZRR9KoXz3QOxOn nsJmEh1O9adJoSRaWpOBC8/0G2V/H/vszH0Cl116knA3WaVHelq4QErK8E+uLfiVTcLz ZjUAREdlbiIwqMsKaHbSXGzmd1ISvhD/K3M1Eae//r2gom10iyHKtG0KOYLw7K1elUHu OhpAkOqayNaLU1x0JFEhYQKId3g6Bq+br0LttK2a11CJdfCfsaconlbQBskXCqTWbdjy 5sQQ== X-Gm-Message-State: AOAM5305D8xjkD0AOxhmjvM4OsmZZJIlzs/FvIj6Gz5HyE2HCnJ/fQcc MuMfw4/prE6ydMn0yhH80x4wvwl+K0Dnkw== X-Google-Smtp-Source: ABdhPJyNN2tda9W7a1HCUjTXe7kF/Y/bP/gmDGdrv3Y58y5PKOI+pMfMJQ7qpdAyRBvhkp6r8Nu3zw== X-Received: by 2002:a05:6214:592:: with SMTP id bx18mr10470996qvb.26.1630912037797; Mon, 06 Sep 2021 00:07:17 -0700 (PDT) Received: from [192.168.2.100] (pool-72-79-19-93.nwrknj.east.verizon.net. [72.79.19.93]) by smtp.gmail.com with ESMTPSA id w6sm5908710qkw.91.2021.09.06.00.07.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Sep 2021 00:07:17 -0700 (PDT) Subject: Re: How to observe plan_cache_mode transition from custom to generic plan? To: Laurenz Albe , pgsql-general@lists.postgresql.org References: <0f9c9510-f4f3-0388-b382-36063f0d4e36@gmail.com> <3968ca671180b32b8199b2a1c1fbf9a43fa14d60.camel@cybertec.at> From: Mladen Gogala Message-ID: <052c4c64-cd0e-9e14-ae9d-ca0e553a3bbf@gmail.com> Date: Mon, 6 Sep 2021 03:07:16 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <3968ca671180b32b8199b2a1c1fbf9a43fa14d60.camel@cybertec.at> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. Creating SQL dynamically from input is the recipe for the "little Bobby Tables" situation: https://xkcd.com/327/ -- Mladen Gogala Database Consultant Tel: (347) 321-1217 https://dbwhisperer.wordpress.com