X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 945BB9DCB3D for ; Wed, 7 Dec 2005 00:15:50 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36571-06 for ; Wed, 7 Dec 2005 00:15:49 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by postgresql.org (Postfix) with ESMTP id 7BDB19DCB3C for ; Wed, 7 Dec 2005 00:15:47 -0400 (AST) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 5960D25078; Wed, 7 Dec 2005 12:15:45 +0800 (WST) Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 1917725070; Wed, 7 Dec 2005 12:15:44 +0800 (WST) Message-ID: <43966290.7090908@familyhealth.com.au> Date: Wed, 07 Dec 2005 12:18:24 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Howard Oblowitz Cc: pgsql-performance@postgresql.org Subject: Re: Query Fails with error calloc - Cannot alocate memory References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-familyhealth-MailScanner-Information: Please contact the ISP for more information X-familyhealth-MailScanner: Found to be clean X-familyhealth-MailScanner-From: chriskl@familyhealth.com.au X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.069 required=5 tests=[AWL=0.069] X-Spam-Score: 0.069 X-Spam-Level: X-Archive-Number: 200512/218 X-Sequence-Number: 16039 If you're trying to retrieve 26 million rows into RAM in one go of course it'll be trouble. Just use a cursor. (DECLARE/FETCH/MOVE) Chris Howard Oblowitz wrote: > Hi … > > I am trying to run a query that selects 26 million rows from a > > table with 68 byte rows. > > When run on the Server via psql the following error occurs: > > calloc : Cannot allocate memory > > When run via ODBC from Cognos Framework Manager only works > > if we limit the retrieval to 3 million rows. > > I notice that the memory used by the query when run on the Server increases > > to about 2.4 GB before the query fails. > > Postgres version is 7.3.4 > > Running on Linux Redhat 7.2 > > 4 GB memory > > 7 Processor 2.5 Ghz > > Shmmax set to 2 GB > > Configuration Parameters > > Shared Buffers 12 288 > > Max Connections 16 > > Wal buffers 24 > > Sort Mem 40960 > > Vacuum Mem 80192 > > Checkpoint Timeout 600 > > Enable Seqscan false > > Effective Cache Size 200000 > > > Results of explain analyze and expain analyze verbose: > > explain analyze select * from flash_by_branches; > > QUERY > PLAN > > ---------------------------------------------------------------------------------------------------------------------------------------------- > > Seq Scan on flash_by_branches (cost=100000000.00..100567542.06 > rows=26854106 width=68) (actual time=12.14..103936.35 rows=26854106 loops=1) > > Total runtime: 122510.02 msec > > (2 rows) > > explain analyze verbose: > > { SEQSCAN > > :startup_cost 100000000.00 > > :total_cost 100567542.06 > > :rows 26854106 > > :width 68 > > :qptargetlist ( > > { TARGETENTRY > > :resdom > > { RESDOM > > :resno 1 > > :restype 1043 > > :restypmod 8 > > :resname br_code > > :reskey 0 > > :reskeyop 0 > > :ressortgroupref 0 > > :resjunk false > > } > > :expr > > { VAR > > :varno 1 > > :varattno 1 > > :vartype 1043 > > :vartypmod 8 > > :varlevelsup 0 > > :varnoold 1 > > :varoattno 1 > > } > > } > > { TARGETENTRY > > :resdom > > { RESDOM > > :resno 2 > > :restype 23 > > :restypmod -1 > > :resname fty_code > > :reskey 0 > > :reskeyop 0 > > :ressortgroupref 0 > > :resjunk false > > } > > :expr > > { VAR > > :varno 1 > > :varattno 2 > > :vartype 23 > > :vartypmod -1 > > :varlevelsup 0 > > :varnoold 1 > > :varoattno 2 > > } > > } > > { TARGETENTRY > > :resdom > > { RESDOM > > :resno 3 > > :restype 1082 > > :restypmod -1 > > :resname period > > :reskey 0 > > :reskeyop 0 > > :ressortgroupref 0 > > :resjunk false > > } > > :expr > > { VAR > > :varno 1 > > :varattno 3 > > :vartype 1082 > > :vartypmod -1 > > :varlevelsup 0 > > :varnoold 1 > > :varoattno 3 > > } > > } > > { TARGETENTRY > > :resdom > > { RESDOM > > :resno 4 > > :restype 1700 > > :restypmod 786436 > > :resname value > > :reskey 0 > > :reskeyop 0 > > :ressortgroupref 0 > > :resjunk false > > } > > :expr > > { VAR > > :varno 1 > > :varattno 4 > > :vartype 1700 > > :vartypmod 786436 > > :varlevelsup 0 > > :varnoold 1 > > :varoattno 4 > > } > > } > > { TARGETENTRY > > :resdom > > { RESDOM > > :resno 7 > > :restype 1700 > > :restypmod 786438 > > :resname value1 > > :reskey 0 > > :reskeyop 0 > > :ressortgroupref 0 > > :resjunk false > > } > > :expr > > { VAR > > :varno 1 > > :varattno 7 > > :vartype 1700 > > :vartypmod 786438 > > :varlevelsup 0 > > :varnoold 1 > > :varoattno 7 > > } > > } > > ) > > :qpqual <> > > :lefttree <> > > :righttree <> > > :extprm () > > :locprm () > > :initplan <> > > :nprm 0 > > :scanrelid 1 > > } > > Seq Scan on flash_by_branches (cost=100000000.00..100567542.06 > rows=26854106 width=68) (actual time=6.59..82501.15 rows=2685 > > 4106 loops=1) > > Total runtime: 102089.00 msec > > (196 rows) > > > > Please assist. > > Thanks, > > Howard Oblowitz > > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.859 / Virus Database: 585 - Release Date: 14/02/2005 > >