Re: [QUESTIONS] Postgresql dies with "FATAL 1: palloc failure: memory exhausted" - Mailing list pgsql-hackers

From Vadim B. Mikheev
Subject Re: [QUESTIONS] Postgresql dies with "FATAL 1: palloc failure: memory exhausted"
Date
Msg-id 3522EBD7.B5371AB8@sable.krasnoyarsk.su
Whole thread Raw
List pgsql-hackers
Chris Albertson wrote:
>
> This is just one example.  ++Every time++ I do a SELECT where
> the expected result is a large number of rows I get a
> failure of some type.
>
> testdb=> select count(*) from tassm16
> testdb-> where 15.5 < b_mag::float4 - (0.375 * (b_mag -
>          r_mag)::float4);
> FATAL 1:  palloc failure: memory exhausted
> testdb=>
>
> I can make Postgresql 6.3 fail every time.  Just do a SELECT
> where the number of rows returned is > a few million.  The

0.375 above is float8 and so server uses two float8 funcs to
calculate right op of '<' ==> 2 * palloc(8) for each row.
palloc(8) eats more than 8 bytes of memmory (~ 24): 2 * 24 = 48,
48 * 1_million_of_rows = 48 Mb.

This is problem of all data types passed by ref !!!
And this is old problem.

Vadim

pgsql-hackers by date:

Previous
From: "Vadim B. Mikheev"
Date:
Subject: Re: [HACKERS] Re: Let's talk up 6.3
Next
From: Cristian Gafton
Date:
Subject: 6.3.1 RH Linux 5.0 packages