Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 9A4949FC0E4 for ; Thu, 21 Jun 2007 15:42:57 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 66011-05 for ; Thu, 21 Jun 2007 15:42:39 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.170]) by postgresql.org (Postfix) with ESMTP id B2ABF9FC0BF for ; Thu, 21 Jun 2007 15:42:34 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id u2so710459uge for ; Thu, 21 Jun 2007 11:42:32 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=GnVFHnahwMD9vei8ZeTixzK2xpBePBertA2EW70UkA3R6rOVEQLdkeo3sdqzFIbcIaZkA7g2GKSqVU+gnoi4ejhxrK11wirHKdxSyfxJg7R1scEbz/AQey2yEqF1nn984PHEWP4Clc5m6ZQLNZZJsrheStBxVJtG2q91Ws6Mxcw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=tqCiGtiSQL4hCnJNXQQBX71c7ANJCkQeufstL8Pr7HXKzXZk3x6PjMFDT615XG7t64zJZOUOikGAhRN4G0R1COulxnthRv3hoAhka6wxG3O6Wty+fa7XGIUYzPN4L1Y8CbCBJTzmCK3MFoeSSVDr71hQOEFgtCW7XFhPug/imDw= Received: by 10.67.28.2 with SMTP id f2mr2211794ugj.1182451352660; Thu, 21 Jun 2007 11:42:32 -0700 (PDT) Received: from ?192.168.1.33? ( [81.107.198.252]) by mx.google.com with ESMTP id m1sm2205541ugc.2007.06.21.11.42.29 (version=SSLv3 cipher=RC4-MD5); Thu, 21 Jun 2007 11:42:30 -0700 (PDT) Message-ID: <467AC673.6080107@enterprisedb.com> Date: Thu, 21 Jun 2007 19:41:55 +0100 From: Heikki Linnakangas User-Agent: Icedove 1.5.0.10 (X11/20070329) MIME-Version: 1.0 To: Steven Flatt CC: pgsql-performance@postgresql.org Subject: Re: Very long SQL strings References: <357fa7590706211133u2ae43d09id1653ca63d7a7838@mail.gmail.com> In-Reply-To: <357fa7590706211133u2ae43d09id1653ca63d7a7838@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/482 X-Sequence-Number: 25515 Steven Flatt wrote: > It looks like Postgres does not enforce a limit on the length of an SQL > string. Great. However is there some point at which a query string > becomes > ridiculously too long and affects performance? Here's my particular case: > consider an INSERT statement where you're using the new multi-row VALUES > clause or SELECT ... UNION ALL to group together tuples. Is it always > better to group as many together as possible? I'm sure you'll reach a point of diminishing returns, and eventually a ceiling where you run out of memory etc, but I don't know what the limit would be. The most efficient way to do bulk inserts is to stream the data with COPY. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com