Re: Query hangs when getting too complex... - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Query hangs when getting too complex...
Date
Msg-id 20011219061828.A70705-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Query hangs when getting too complex...  (Paulo Jan <admin@digital.ddnet.es>)
List pgsql-general
>     SELECT count(idarchivo)  FROM archivos  WHERE
>     revision <= 3 AND (EXISTS
>     (SELECT idarchivo FROM archivos_fulltext_en WHERE revision <= 3
>     AND archivos_fulltext_en.idarchivo=archivos.idarchivo
>     AND LOWER(TRANSLATE(archivos_fulltext_en.title ||
> archivos_fulltext_en.description || archivos_fulltext_en.place ||
> archivos_fulltext_en.province || archivos_fulltext_en.state ||
> archivos_fulltext_en.country || archivos_fulltext_en.race ||
> archivos_fulltext_en.sex || archivos_fulltext_en.class ||
> archivos_fulltext_en.tesauro_en, '[����������]', '[aeiouAEIOU]')) LIKE
> '%actress%'))
>     AND idsexo=2 AND archivos.joven = 1 AND posado=1
>     AND fechafoto BETWEEN '01/1/1976' AND '19/12/2001'

That's wierd. What does explain show for the query?

BTW: If you're always using the archivos_fulltext_en values like the above
and inserts/updates are less frequent than these selects, you might want
to do a trigger that does the lower(translate()) for you when the rows are
added.
As an additional note, I don't think the query above does what you want in
any case unless there are delimiters at the beginings or end of the
strings you're concatenating, and if any of the strings is null the result
of the concatenation is null. (Imagine that description ends in act and
place starts with ress for example)



pgsql-general by date:

Previous
From: Joe Koenig
Date:
Subject: Re: Way to use count() and LIMIT?
Next
From: Troy.Campano@LibertyMutual.com
Date:
Subject: Outputting select into file.