From: Josh Berkus <josh@agliodbs.com>
To: Dror Matalon <dror@zapatec.com>
To: pgsql-performance@postgresql.org
Subject: Re: Speeding up Aggregates
Date: Fri, 3 Oct 2003 14:07:10 -0700
Message-ID: <200310031407.10343.josh@agliodbs.com> (raw)
In-Reply-To: <20031003202120.GO87525@rlx11.zapatec.com>
References: <20031003202120.GO87525@rlx11.zapatec.com>
Dror,
> select articlenumber, channel, description, title, link, dtstamp from
> items, my_channels where items.channel = '22222' and my_channels.id =
> '22222' and owner = 'drormata' and dtstamp > last_viewed and
> articlenumber not in (select item from viewed_items where channel
> ='22222' and owner = 'drormata');
the NOT IN is a bad idea unless the subselect never returns more than a
handful of rows. If viewed_items can grow to dozens of rows, wyou should
use WHERE NOT EXISTS instead. Unless you're using 7.4.
> item_max_date() looks like this:
> select max(dtstamp) from items where channel = $1 and link = $2;
Change it to
SELECT dtstamp from iterm where channel = $1 and link = $2
ORDER BY dtstamp DESC LIMIT 1
and possibly build an index on channel, link, dtstamp
--
-Josh Berkus
Aglio Database Solutions
San Francisco
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: josh@agliodbs.com, dror@zapatec.com
Subject: Re: Speeding up Aggregates
In-Reply-To: <200310031407.10343.josh@agliodbs.com>
* 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