Re: Problem with SQL query (eats swap)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-sql(at)ruby(dot)sartorelli(dot)gen(dot)nz (Mailing List Expander)
Cc: pgsql-sql(at)hub(dot)org
Subject: Re: Problem with SQL query (eats swap)
Date: 2000-08-11 15:53:55
Message-ID: 2538.966009235@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

pgsql-sql(at)ruby(dot)sartorelli(dot)gen(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Mark Volpe 2000-08-11 16:03:48 Re: Rules aren't doing what I expect
Previous Message Tom Lane 2000-08-11 14:10:30 Re: Rules aren't doing what I expect