Thread

  1. Re: [HACKERS] having and union in v7beta

    Jose Soares <jose@sferacarta.com> — 2000-03-01T13:24:14Z

    Tom Lane wrote:
    
    > Jose Soares <jose@sferacarta.com> writes:
    > > I tried the following query :
    >
    > > select * from comuni where nome in (
    > >      select nome from comuni group by nome having 1 < count(nome)
    > >      );
    >
    > > on the above table populated with 8342 rows, PostgreSQL begins searching
    > > and I wait for hours without any result.
    >
    > I'd expect that to be pretty slow, since it's going to execute the inner
    > select for every tuple examined by the outer select.  Shouldn't be any
    > worse than 6.5 though.  IN (sub-SELECT) has always been slow.
    >
    >
    
    In v7.0 this query takes more than 50min to execute, it doesn't work on
    v6.5...
    
    select * from comuni where nome in (
         select nome from comuni group by nome having count(nome) > 1
         );
    
    real    50m25.033s
    user    0m0.010s
    sys     0m0.000s
    
    --
    Jose' Soares
    Bologna, Italy                     Jose@sferacarta.com