From: Josh Berkus <josh@agliodbs.com>
To: Karl Denninger <karl@denninger.net>
To: pgsql-performance@postgresql.org
Subject: Re: Why is query selecting sequential?
Date: Fri, 6 Feb 2004 14:36:57 -0800
Message-ID: <200402061436.57903.josh@agliodbs.com> (raw)
In-Reply-To: <20040206162232.D4910@Denninger.Net>
References: <20040206153602.B4910@Denninger.Net>
<200402061351.39084.josh@agliodbs.com>
<20040206162232.D4910@Denninger.Net>
Karl,
Well, still with only 5 rows in the forumlog table you're not going get
realistic results compared to a loaded database. However, you are making
things difficult for the parser with awkward query syntax; what you currently
have encourages a sequential loop.
If there are potentially several rows in forumlog for each row in post, then
your query won't work either.
> akcs=> explain analyze select forum, (replied > (select lastview from
forumlog where forumlog.login='genesis' and forumlog.forum='General' and
number=post.number)) as newflag, * from post where forum = 'General' and
toppost = 1 order by pinned desc, replied desc;
Instead:
if only one row in forumlog per row in post:
SELECT (replied > lastview) AS newflag, post.*
FROM post, forumlog
WHERE post.forum = 'General' and toppost = 1 and forumlog.login = 'genesis'
and forumlog.forum='General' and forumlog.number=post.number;
--
-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, karl@denninger.net
Subject: Re: Why is query selecting sequential?
In-Reply-To: <200402061436.57903.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