Обсуждение: Selecting from a Subquery Fails

Поиск
Список
Период
Сортировка

Selecting from a Subquery Fails

От
Francesco Pari
Дата:
Hello, i have this big isuue:


i have 2 table referenced by this columns
codiceregistrazione=riferimentoesame;


select tipoesame,count(*) from righeaccettazione,registrazione where
codiceregistrazione=riferimentoesame and validita='VALIDO' and
dataesame  between timestamp '2008-01-01 00:00:00' and '2008-12-31
23:58:59' and eseguitonellasegreteria=1 and ticket <> 2 and
repartoprovenienza=81   group by tipoesame order by tipoesame;


this query works fine (4 seconds to run as it is a large data set) and
produces 245 rows of values in 2 columns


if i try


select * from (

select tipoesame,count(*) as tot from righeaccettazione,registrazione
where codiceregistrazione=riferimentoesame and validita='VALIDO' and
dataesame  between timestamp '2008-01-01 00:00:00' and '2008-12-31
23:58:59' and eseguitonellasegreteria=1 and ticket <> 2 and
repartoprovenienza=81   group by tipoesame order by tipoesame)

as ciao where ciao.tipoesame=615 ;


The query Hangs ....

can this be a bug or a misconfiguration?

thanks in advance

Re: Selecting from a Subquery Fails

От
Euler Taveira de Oliveira
Дата:
Francesco Pari escreveu:
> The query Hangs ....
>
> can this be a bug or a misconfiguration?
>
It isn't a bug unless you show us a backend's crash, memory leak, or another
misbehavior. I suspect the second query is suffering from a bad plan. Try
posting EXPLAIN ANALYZE of both queries to pgsql-performance (this is not the
right list for such a question).


--
  Euler Taveira de Oliveira
  http://www.timbira.com/