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 1q9syN-0004hd-Tc for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jun 2023 19:49:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q9syL-0004DS-0x for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jun 2023 19:49:33 +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 1q9syK-0004DJ-Nw for pgsql-hackers@lists.postgresql.org; Thu, 15 Jun 2023 19:49:32 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q9syI-002P6K-37 for pgsql-hackers@postgresql.org; Thu, 15 Jun 2023 19:49:31 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f8cec6641bso24250085e9.1 for ; Thu, 15 Jun 2023 12:49:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garret-ru.20221208.gappssmtp.com; s=20221208; t=1686858568; x=1689450568; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=7ZUm9jCPEQVqD3F3/UH0sjxIH/fA/atFXVpwvk3w/LI=; b=Itr2CL5llffAYCkH3ca34aAN3QdJ0dubQl1OPczhMJh1Qm1PDJjUmM95NJTH8QHqfA /rjSNns/gEZQ/vph0pXn7vTlQ4bUOF+VHsBQwJqTXCfuR98StS7EQOFly8+c34c+Wche fFoXjeSQ/Xk5Mtd3/emnuCNZNPxzC5nCUJcFDEpHonQfxO8uqSkrDMT8vLyEtWgLSzGJ 88tIjRdqyLz16wK/SXzNVs50ZK0KPea+JCwoz/sV85mDxWCiVObnxaVMCAxyJvp5aEkr 3SjQnMoBfZPh/rmaz0b42Z2NHXAs5/FAWCmfh5qn/C/lMzMFAz4PAalDnrCrM6qTli4A IfcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686858568; x=1689450568; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7ZUm9jCPEQVqD3F3/UH0sjxIH/fA/atFXVpwvk3w/LI=; b=OJAZFuHUcb0kyWwtk6esa+IXyJqZGPsBAos3G+zLmhFuYQUTA0z2Qk97wUsVlf84NT Z/kaq1L8CnPlP0XcKu9GakjyxUsjebJLh1ir0zmmHFsaYQYNI/7xkDOf4RhhiKD/9OPk J4BtWr/KBBKUT89IwwrtI8lci0w/+0D9xqVIPghYafBbVQgife1TMkSM+Z7WG3rTrslk CZhFuwD4UOaIBQ6U3pfVzSTKuPE+0+NKMhDdNzS4CHMi+T+OF5vaOeb6MZTx43eyqgJL bHAIltUZFcS7DwUcoFM5XuE6k03UXF8pgwhTyVMY2M6sqdD5JBlcbibI3HK62n23eBFy kgSA== X-Gm-Message-State: AC+VfDyaW4JpvcrCW2zBecVCxjhTc3zqWuA9DQAj5raH+DEGf/LbbtdS C4qEIKR3BPgqG9jBNgn9Ry3+yg== X-Google-Smtp-Source: ACHHUZ7Ujv34kmfmcNqFcsDbh/dYMX/1EsvLd7ctXLsm2tIjWLagsrXbbYUxypz4LhtbFapzf3HkCA== X-Received: by 2002:a05:600c:2103:b0:3f7:f7b5:7813 with SMTP id u3-20020a05600c210300b003f7f7b57813mr195296wml.19.1686858566970; Thu, 15 Jun 2023 12:49:26 -0700 (PDT) Received: from [192.168.2.28] ([217.175.216.56]) by smtp.gmail.com with ESMTPSA id z11-20020a05600c220b00b003f60101074dsm46591wml.33.2023.06.15.12.49.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jun 2023 12:49:26 -0700 (PDT) Message-ID: <361f63ed-2a1a-7b1f-65a2-d7cadee76937@garret.ru> Date: Thu, 15 Jun 2023 22:49:23 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: Let's make PostgreSQL multi-threaded Content-Language: en-US To: Hannu Krosing , James Addison Cc: Pavel Borisov , Dilip Kumar , Heikki Linnakangas , pgsql-hackers References: <31cc6df9-53fe-3cd9-af5b-ac0d801163f4@iki.fi> <2c2665d2-c513-c12e-9097-9b1805bc2471@garret.ru> <36f61a71-3bbb-b7b0-0d99-db5e69715af7@garret.ru> From: Konstantin Knizhnik 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 15.06.2023 12:04 PM, Hannu Krosing wrote: > So a fair bit of work but also a clearly defined benefits of > 1) reduced memory usage > 2) no need to rebuild caches for each new connection > 3) no need to track PREPARE statements inside connection poolers. Shared plan cache (not only prepared statements cache) also opens way to more sophisticated query optimizations. Right now we are not performing some optimization (like constant expression folding) just because them increase time of processing normal queries. This is why queries generated by ORMs or wizards, which can contain a lot of dumb stuff, are not well simplified  by Postgres. With MS-Sql it is quite frequent that query execution time is much smaller than query optimization time. Having shared plan cache allows us to spend more time in optimization without risk to degrade performance.