BUG #5239: Recursive complex query

Started by Recursive complex queryover 16 years ago2 messagesbugs
Jump to latest
#1Recursive complex query
gusta1308@gmail.com

The following bug has been logged online:

Bug reference: 5239
Logged by: Recursive complex query
Email address: gusta1308@gmail.com
PostgreSQL version: 8.4
Operating system: Windows XP SP 2
Description: Recursive complex query
Details:

I try to run following query:

with recursive data (cid, rid, fini, ffin) as (
select
po1.cliente_id,
po1.ramo_id,
po1.inicio,
po1.final
from tm_polizas po1
inner join (
select
pol.cliente_id,
pol.ramo_id,
max(pol.final) final
from tm_polizas pol
where pol.final >= (date '2009-01-01')
group by pol.cliente_id,
pol.ramo_id
) x1
on x1.cliente_id = po1.cliente_id
and x1.ramo_id = po1.ramo_id
and x1.final = po1.final

union all

select
po2.cliente_id,
po2.ramo_id,
po2.inicio,
data.ffin final
from tm_polizas po2
inner join data
on po2.cliente_id = data.cid
and po2.ramo_id = data.rid
and po2.final >= (fini - 90)
)
select
cid cliente_id,
rid ramo_id,
min(fini) inicio,
max(ffin) final
from data
group by cid, rid;

and the server report me the error: "ERROR: write failed"

This table contain 5 million rows

Thank

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Recursive complex query (#1)
Re: BUG #5239: Recursive complex query

"Recursive complex query" <gusta1308@gmail.com> writes:

and the server report me the error: "ERROR: write failed"

Maybe you ran out of disk space? Are you sure the recursion terminates
at all, or does so before generating an enormous number of rows?

regards, tom lane