I'm on 7.3.4 and this query gets horrible performance. Is there a way to rewrite it with an exists or some way to get better performance?
select code, id, name, date_of_service from tbl where date_of_service in (select date_of_service from tbl where xxx >= '29800' and xxx <= '29909' and code = 'XX') and client_code = 'XX' order by id, date_of_service; Thanks! ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org