X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8F28752932 for ; Thu, 9 Jun 2005 04:31:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89051-06 for ; Thu, 9 Jun 2005 07:31:50 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) by svr1.postgresql.org (Postfix) with ESMTP id 445095292B for ; Thu, 9 Jun 2005 04:31:49 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 69so4904wra for ; Thu, 09 Jun 2005 00:31:50 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=JxSgLyEUuFBtsfvW1WMcV4t5uVXwwIUW5WNJz2d7jX01Ac3ArlqC+QNm5qJmKwGMk7o/Gm1Vd67S6fkFtaFzvNM9TtViQZ8RgOssRolrkWJhy2iFeKEKpF4YdXTJzSSWKa97sRbrbKQXxTpoTrotRKp4mZHaicWa8p+YSVQWJn4= Received: by 10.54.33.53 with SMTP id g53mr201656wrg; Thu, 09 Jun 2005 00:31:50 -0700 (PDT) Received: by 10.54.30.45 with HTTP; Thu, 9 Jun 2005 00:31:50 -0700 (PDT) Message-ID: <7104a7370506090031c8617d3@mail.gmail.com> Date: Thu, 9 Jun 2005 10:31:50 +0300 From: Volkan YAZICI Reply-To: Volkan YAZICI To: Thomas Kellerer Subject: Re: SELECT very slow Cc: pgsql-sql@postgresql.org In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <27961.1118275606@sss.pgh.pa.us> <42A797B5.3060300@pobox.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.143 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200506/133 X-Sequence-Number: 21734 Hi, On 6/9/05, Thomas Kellerer wrote: > No I want the whole result. As Tom underlined: On 6/9/05, Tom Lane wrote: > The solution is to use a cursor and FETCH a reasonably > small number of rows at a time. AFAIC, query results are stored as arrays in PGresult structures. Thus, storing huge result sets in a single struct is not very feasible; although, you can face with theoretical limits like MAX_INT in the long run. Moreover, it's so rare to see any practical use of retrieving thousands of rows. If you're getting quite huge sets of data, you should try grouping them with suitable statements. IMHO, you should use cursors to fetch a suitable amount of row from related table and forward it recursively. (Furthermore, I think this is one of the design goals of FETCH mechanism.) Although, as I see from most API implementations (like C++, Perl, PHP, Python and etc.), they use libpq as layer between API and server. Therefore, you'll probably encounter with every limitation of libpq with other programming languages out of C too. Regards.