Hello what is your settings for random_page_cost, seq_page_cost and work_mem? Regards Pavel Stehule 2011/6/8 Tony Capobianco <tcapobianco@xxxxxxxxxxxxxx>: > Here's the explain analyze: > > pg_dw=# explain analyze CREATE TABLE ecr_opens with (FILLFACTOR=100) > as > select o.emailcampaignid, count(memberid) opencnt > Âfrom openactivity o,ecr_sents s > Âwhere s.emailcampaignid = o.emailcampaignid > Âgroup by o.emailcampaignid; > > QUERY > PLAN > ---------------------------------------------------------------------------------------------------------------------------------------------------------------- > ÂGroupAggregate Â(cost=0.00..1788988.05 rows=9939 width=12) (actual > time=308630.967..2592279.526 rows=472 loops=1) > Â -> ÂNested Loop Â(cost=0.00..1742467.24 rows=9279316 width=12) > (actual time=31.489..2589363.047 rows=8586466 loops=1) > Â Â Â Â -> ÂIndex Scan using ecr_sents_ecid_idx on ecr_sents s > (cost=0.00..38.59 rows=479 width=4) (actual time=0.010..13.326 rows=479 > loops=1) > Â Â Â Â -> ÂIndex Scan using openact_emcamp_idx on openactivity o > (cost=0.00..3395.49 rows=19372 width=12) (actual time=1.336..5397.139 > rows=17926 loops=479) > Â Â Â Â Â Â Â Index Cond: (o.emailcampaignid = s.emailcampaignid) > ÂTotal runtime: 2592284.336 ms > > > On Wed, 2011-06-08 at 17:31 +0200, tv@xxxxxxxx wrote: >> > On Postgres, this same query takes about 58 minutes (could not run >> > explain analyze because it is in progress): >> > >> > pg_dw=# explain CREATE TABLE ecr_opens with (FILLFACTOR=100) >> > pg_dw-# as >> > pg_dw-# select o.emailcampaignid, count(memberid) opencnt >> > pg_dw-# Â from openactivity o,ecr_sents s >> > pg_dw-# Âwhere s.emailcampaignid = o.emailcampaignid >> > pg_dw-# Âgroup by o.emailcampaignid; >> > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂQUERY >> > PLAN >> > ------------------------------------------------------------------------------------------------------------- >> > ÂGroupAggregate Â(cost=0.00..1788988.05 rows=9939 width=12) >> > Â Â-> ÂNested Loop Â(cost=0.00..1742467.24 rows=9279316 width=12) >> > Â Â Â Â Â-> ÂIndex Scan using ecr_sents_ecid_idx on ecr_sents s >> > (cost=0.00..38.59 rows=479 width=4) >> > Â Â Â Â Â-> ÂIndex Scan using openact_emcamp_idx on openactivity o >> > (cost=0.00..3395.49 rows=19372 width=12) >> > Â Â Â Â Â Â Â ÂIndex Cond: (o.emailcampaignid = s.emailcampaignid) >> > (5 rows) >> > >> >> Please, post EXPLAIN ANALYZE, not just EXPLAIN. Preferably using >> explain.depesz.com. >> >> regards >> Tomas >> >> > > > > -- > Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-performance > -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance