Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TLedU-0005Mm-NR for pgsql-bugs@postgresql.org; Tue, 09 Oct 2012 18:34:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TLedT-0006km-4Q for pgsql-bugs@postgresql.org; Tue, 09 Oct 2012 18:34:32 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q99IYRVN002283; Tue, 9 Oct 2012 14:34:27 -0400 (EDT) From: Tom Lane To: pking@nrcan.gc.ca cc: pgsql-bugs@postgresql.org Subject: Re: BUG #7591: Large query string has limit In-reply-to: References: Comments: In-reply-to pking@nrcan.gc.ca message dated "Tue, 09 Oct 2012 15:24:23 -0000" Date: Tue, 09 Oct 2012 14:34:27 -0400 Message-ID: <2282.1349807667@sss.pgh.pa.us> X-Pg-Spam-Score: -4.0 (----) X-Archive-Number: 201210/68 X-Sequence-Number: 34368 pking@nrcan.gc.ca writes: > I am dealing with the open source program called "Geonetwork". It is passing > the following query to postgres/postgis : > SELECT "fid", asText("the_geom") FROM "public"."spatialindex" WHERE ("fid" = > '10') OR ("fid" = '100') OR ("fid" = '1000') OR ("fid" = '10001') OR ("fid" > = '10005') .......... > Unfortunately, the query has > 50,000 OR clauses, and the query hangs. [ rolls eyes ... ] You will not find a lot of DBMSes that don't have indigestion with that. It's possible that converting to an IN list would be less inefficient, but personally I'd suggesting putting all the target IDs into a temp table and joining to that. regards, tom lane