pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-sql@ruby.sartorelli.gen.nz
Cc: pgsql-sql@hub.org
Subject: Re: Problem with SQL query (eats swap)
Date: Fri, 11 Aug 2000 11:53:55 -0400
Message-ID: <2538.966009235@sss.pgh.pa.us> (raw)
In-Reply-To: <m13N4px-003bmOC@ruby.sartorelli.gen.nz>
References: <m13N4px-003bmOC@ruby.sartorelli.gen.nz>

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



view thread (2+ messages)

Message-ID: <2538.966009235@sss.pgh.pa.us>
Permalink:  ../2538.966009235@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2538.966009235@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-sql@ruby.sartorelli.gen.nz, pgsql-sql@hub.org
  Subject: Re: Problem with SQL query (eats swap)
  In-Reply-To: <2538.966009235@sss.pgh.pa.us>
  References: <m13N4px-003bmOC@ruby.sartorelli.gen.nz> <2538.966009235@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox