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 1spCba-00HNcz-Jp for pgsql-general@arkaria.postgresql.org; Fri, 13 Sep 2024 20:09:23 +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 1spCac-00B8Y2-9r for pgsql-general@arkaria.postgresql.org; Fri, 13 Sep 2024 20:08:22 +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.94.2) (envelope-from ) id 1spCab-00B8Xt-Sx for pgsql-general@lists.postgresql.org; Fri, 13 Sep 2024 20:08:21 +0000 Received: from mout.gmx.net ([212.227.15.15]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1spCaY-0012fD-FE for pgsql-general@lists.postgresql.org; Fri, 13 Sep 2024 20:08:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1726258099; x=1726862899; i=shammat@gmx.net; bh=h+N1Soro5D5nqsl+8RXc6qiliiHCIH0AnLvEmYa9ivk=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=plUSbvV/HTAlk9rdArQ+LcA1l/8dtGAzkKGZHdS7MB6OO8to6lWTKhM9WaFlrOoV Nogw6tJKTR/kmivtzT1lxGLvFtHEcxnEi6ElhWNNp1VuVDY0J8T3a53VjK2ZdUmm5 N9Gs6NIDT7h9XH/lnThKkacQfdEu/jESphci6Fe7Jzu1pynPJQNJSG21t1ns2AMle O1LFuaqlJxtTD6Coy0vjohLMLyGm2Qpx0i4DdhmD5ygVl14r8+gkvUfj5FxnDZaCy GxrTFwW8YELVPCej+YRQjrCBxa6tCF1j3ff9Ka9g0aPZ93+MrVRv8l5smDXFISUbi 4g+9gRlCDFQDu9LWGg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.31] ([88.217.180.75]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MpUUw-1sCZyQ3aY8-00ZT3o for ; Fri, 13 Sep 2024 22:08:18 +0200 Message-ID: Date: Fri, 13 Sep 2024 22:08:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Will hundred of thousands of this type of query cause Parsing issue To: pgsql-general@lists.postgresql.org References: Content-Language: de-DE, en-US From: shammat@gmx.net In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:8cB3qyEslnMZCmr02C1YhswsVxcJu6CGSMbqokeBagU6IImK0Ce 8QzWAfrzGUpG2xhdl49gB3dn7ywO1wUSvahBK59S8iBVohmS0arAucD/0kQOTeICqCZZFXE CMBThV7VTktYN+Whn93KJMMB82bqWyvl6vIVqqDTzxxt1nUrXVxsCRt7jonN4fU6I02Y5wj H5jFEHQqyXTl7KEMGQl5Q== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:e+OXi9sNn5Y=;adWwcrE71MU4hl/w/Rk+bu6RFF5 gJvH5l/r5SpCqrZntcr48YYjbv7T1btcQgmBgSqtzRJ8wXmTNdgKM/UijD6lGpgV0h9ecUktE WkdCdnBMvTISph9IMM5qkYu8I49CHupHFnfjYp/puHA2sYXmHFy+mbKjjJGHdlzTeC6IJXadC G8RLwex1G3q/QCRzFAe3J9S74Z1Q4gbO3xCqXNP6R8SzyCbJwU9ZSpDq5o5SxtFScETNk/Mgz c/oLXRSlpUs/98U/C0pGzkSIPei5fxIz9gbihgwIeJQNzZh/egz8oNZbEWq15P7kt+5VFd9Se wLcPj4rhhWTv9q8qtpRa3Qm7kGnDLEoa3ujjf1KNgkD4i/dRjCtAeZT5yQv2pe+BrvCN6tRjF rcdKv2lHvbom3uQcpkgMfOZnGFcj8cGYsRYlEuiPKM8/UyNfMwAA1QU+6QkWkSpNj9N7IP/P2 xHpKRC7AKy4FY5O5pHsiz1+srchspjyMKWpInITV3JWTe98HtDYTYsxODhwOFMETiD+NFrTQS dBWGuMCp+KX92kPUJHbyMom9tUmfjl0zDgQfdQM3vLo+MR7/lKmUu8uLz0WVIEKH5MbemYq9G 3hJRwYnHaDjGmf17Fe3tsMSegG1RJ8R0kH83Ul49NWTNP5TmA7vlJHJSlL863Kb1jQXeGI3l3 wLWv6UV8lZMcxi1mXBxgDif8+iXgb1gsgT80lI5a6mQstN/m1l1KxG/8iPxrZ1RvbrzMLO+fY BurQbWu9Fk9ny8KYKyFzCJ5eR9/VmGKsqB2HE0gxyewClUevSQoVs4NYdJti6OE+mERO5OYX5 mXQvL1TUThDDYGXg6VgGub1A== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Am 13.09.24 um 17:34 schrieb Wong, Kam Fook (TR Technology): > We have a flavor of this type of query with long in-list/bind > variables (see below). We notice that some of the bind variables > come in as 0 which causes the optimizer to choose to full scan two of > the following 3 tables. One thought to fix a full table scan is to > chop off the not-needed bind variables (proven to work after some > tests). But my other worry is will cause parsing issues because the > app will be executing > 100k/sec with this type of query. > > I am an Oracle DBA, and this change for sure will generate a > different query id. Which in turn generates tons of extra parsing to > the DB because all soft and hard parsing occurs at the DB level. But > my understanding for Postgres is parsing occurs at the client jdbc > level. Am I understanding this correctly? > > In summary/my concern: > > 1) Where does query parsing occur? > 2) Will this cause extra parsing to the posgress DB?=C2=A0 Any pg system= table to measure parsing? > You can simplify the query to a single parameter by passing the list of va= lues as an array: SELECT abc, efg from DOCLOC a, COLLECTION b WHERE a.colum1 =3D ANY($1) AND a.COLLECTION_NAME=3Db.DOCLOC.COLLECTION_NAME AND a.DOCLOC.STAGE_ID=3D(SELECT MAX (STAGE_ID) FROM COLLECTION_PIT WHERE COLLECTION_PIT.COLLECTION_NAME=3Da.COLLECT= ION_NAME AND COLLECTION_PIT.PIT_ID<=3D$1001 AND COLLECTIO= N_PIT.STAGE_CODE=3D$2) You can then pass the array using PreparedStatement.setArray() This has the additional advantage that you don't need to build the query d= ynamically and there is only a single statement to be parsed. I don't think Postgres = distinguishes between soft and hard parses as it doesn't cache plans as aggressively as = Oracle.