Re: INDEX suggestion needed

From: Thomas Beutin <tyrone(at)laokoon(dot)IN-Berlin(dot)DE>
To: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: INDEX suggestion needed
Date: 2002-12-11 19:15:13
Message-ID: 20021211201513.B14025@laokoon.bug.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Dec 11, 2002 at 10:49:11AM -0800, Jeff Eckermann wrote:
> --- Thomas Beutin <tyrone(at)laokoon(dot)IN-Berlin(dot)DE> wrote:
> > My typical queries are like that:
> > SELECT count(a_id) AS count
> > FROM (
> > SELECT DISTINCT a_id FROM stat_pages
> > WHERE m_id = '35'
> > AND visit >= '2002-09-01'
> > AND visit <= '2002-09-30'
> > ) AS foo;
> >
>
> You can do SELECT count(DISTINCT a_id) FROM ...
It looks little bit better, but the inner select is a sequence scan as well :-(
Explain:
EXPLAIN SELECT count(DISTINCT a_id) FROM stat_pages WHERE m_id = '35' AND visit >= '2002-09-01' AND visit <= '2002-09-30';
NOTICE: QUERY PLAN:

Aggregate (cost=14304.30..14304.30 rows=1 width=34)
-> Seq Scan on stat_pages (cost=0.00..13821.19 rows=193241 width=34)

Thanks,
-tb
--
Thomas Beutin tb(at)laokoon(dot)IN-Berlin(dot)DE
Beam me up, Scotty. There is no intelligent live down in Redmond.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lincoln Yeoh 2002-12-11 19:18:16 Re: Postgresql and Ruby - any opensource software
Previous Message Thomas Beutin 2002-12-11 19:09:52 Re: INDEX suggestion needed