From: | Josh Berkus <josh(at)agliodbs(dot)com> |
---|---|
To: | Karl Denninger <karl(at)denninger(dot)net>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Why is query selecting sequential? |
Date: | 2004-02-06 22:36:57 |
Message-ID: | 200402061436.57903.josh@agliodbs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Orion Henry | 2004-02-07 01:02:10 | Re: 7.3 vs 7.4 performance |
Previous Message | Karl Denninger | 2004-02-06 22:22:32 | Re: Why is query selecting sequential? |