On Wed, Dec 11, 2002 at 10:49:11AM -0800, Jeff Eckermann wrote:
> --- Thomas Beutin <tyrone@laokoon.IN-Berlin.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@laokoon.IN-Berlin.DE
Beam me up, Scotty. There is no intelligent live down in Redmond.