Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 0E6C76326BC for ; Tue, 15 Jun 2010 06:50:17 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 94384-01 for ; Tue, 15 Jun 2010 09:50:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) by mail.postgresql.org (Postfix) with ESMTP id A5E1E632698 for ; Tue, 15 Jun 2010 06:50:09 -0300 (ADT) Received: by fxm10 with SMTP id 10so8494fxm.19 for ; Tue, 15 Jun 2010 02:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=CqEwLFmG04u727AHNze7+XZhBuXzGl8qRKm+KTDIjMg=; b=iyXdM7n5WYm1K1KOWz4Rr2MVATL8qz7MO6MKgNkMrc2/i2/LDosNtf78YOzz0ECpQ5 38rt5s9GKmRUfYzf3XuQoY8/u2rdtiUb+mTW8X4Ixeqyf6m9Cz8FPsdKkQW6nEvkpOBP XCwLOkdRjsqM1oaabop2R6ChrtJEw0wINz0ns= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=CCjnYzFF2WSuwptP8RdBwn8K1VQz4TeCrNZZrhBBHGPBBSvBxthhQik8KCrfp9gBd7 hxJi2vhDP+siKgFKJxm/77p0BfhDwh+W+02MDijzTh63NjbIpTAaP07ZvpmhX3+vEwBq N5f1cDgT4WyncrO5oaJu2AwqW7DdFzafvB5zY= Received: by 10.223.99.156 with SMTP id u28mr6800277fan.53.1276595403605; Tue, 15 Jun 2010 02:50:03 -0700 (PDT) Received: from [172.16.253.12] ([217.7.7.23]) by mx.google.com with ESMTPS id s20sm9365481faa.37.2010.06.15.02.49.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 15 Jun 2010 02:49:58 -0700 (PDT) Message-ID: <4C174CC5.5080708@googlemail.com> Date: Tue, 15 Jun 2010 11:49:57 +0200 From: Marco Dieckhoff User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.23) Gecko/20090812 Lightning/0.9 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: pgsql-php@postgresql.org Subject: Re: large resultset References: <8f468dc246fb6075f2a1f46b09f71a6d@xs4all.nl> In-Reply-To: <8f468dc246fb6075f2a1f46b09f71a6d@xs4all.nl> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201006/13 X-Sequence-Number: 4152 Am 15.06.2010 11:40, schrieb vinny: > On Tue, 15 Jun 2010 10:33:05 +0100, Thom Brown > wrote: > >> On 15 June 2010 09:31, AI Rumman wrote: >> How to return large resutlset (almost 2 millions record) in php? >> >> >> Obviously that wouldn't do by itself, but it's quite simple to loop over >> a result set. >> > If that's the case surely you'd use some SQL to merge the data into one > long string and return it in a single record. > Looping over two million results is going to take a while, not to mention > quite a bit of memory. > v. > huh? Returning one large record containg the information of two million records will almost certainly fill up your memory. First the memory of the sql server, in order to process the combination of two million records, and if that's even successfull, the memory of the server processing php. Looping may take "a little" longer, but as only one row at a time is fetched, it should be the least possible memory use. In most cases, you don't want to process every two million datasets in php anyway. You may want to aggregate the data or maybe use created functions on the sql server. regards, Marco