Re: BUG #2428: ERROR: out of memory, running INSERT SELECT statement

From: Casey Duncan <casey(at)pandora(dot)com>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2428: ERROR: out of memory, running INSERT SELECT statement
Date: 2006-05-11 17:13:08
Message-ID: 5F95E3ED-57A3-4DCA-A2F3-DFC238FF7D81@pandora.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


On May 11, 2006, at 4:42 AM, Simon Riggs wrote:

> On Wed, 2006-05-10 at 09:34 -0700, Casey Duncan wrote:
>
>> The script actually fails before the function is even defined anyhow,
>> on this statement:
>>
>> INSERT INTO ss
>> (ss_id, name, ll_id, shared_ss_id, time_added,
>> shared_creator_id)
>> SELECT nextval('ss_id_seq'), s.name, lts.ll_id, s.ss_id,
>> lts.time_added, s.ll_id
>> FROM ss AS s, ll_to_ss AS lts
>> WHERE lts.ll_id != s.ll_id;
>
> As your database is defined, this SQL statement will return
> approximately 4 trillion rows, by my calculation. As you say, it
> returns
> no rows at all when the database is empty.

*slaps forehead* I totally missed the "!=" in the where clause, Doh!
Thanks for hitting me with a clue-stick.

> If it hadn't failed on OOM it would have failed on disk space,
> assuming
> you didn't have a requirement for a 100 Tb table. So fixing this
> problem
> at the server end isn't something that is likely to happen soon/ever.
>
>> From here, your SQL looks like it has an error-of-intention.
>
> [This is exactly the type of statement that statement_cost_limit patch
> would have rejected early with an appropriate message.]

That would be nice, as it is it currently fails in very nasty way.
"ERROR: Query too stupid" might be better for this one ;^)

Thanks much.

-Casey

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2006-05-11 17:15:30 Re: BUG #2432: PID file not created if $PGDATA is different from Datadir
Previous Message Thomas Reiss 2006-05-11 15:48:35 BUG #2432: PID file not created if $PGDATA is different from Datadir