Re: Problem with SQL query (eats swap)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Problem with SQL query (eats swap)
Дата
Msg-id 2538.966009235@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Problem with SQL query (eats swap)  (pgsql-sql@ruby.sartorelli.gen.nz (Mailing List Expander))
Список pgsql-sql
pgsql-sql@ruby.sartorelli.gen.nz (Mailing List Expander) writes:
> select count(*) from attachments a where a.id in (select m.id from
> mail m where m.date < now()-62);

> but ran out of swap.

The problem is that "now()-62" leaks memory to the tune of a few dozen
bytes per evaluation.  In existing releases that memory won't be
reclaimed till end of query.  (This problem is fixed for 7.1, but that
won't help you today.)  Since the inner select is re-executed for each
iteration of the outer select, you have a lot of executions of the
inner WHERE clause, and so even a small leak is a problem.
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Rules aren't doing what I expect
Следующее
От: Mark Volpe
Дата:
Сообщение: Re: Rules aren't doing what I expect