The following bug has been logged online:

Bug reference:      5239
Logged by:          Recursive complex query
Email address:      gusta1...@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

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to