Seq Scan vs Index on Identical Tables in Two Different Databases

From: Ellen Rothman <erothman(at)datalinedata(dot)com>
To: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Seq Scan vs Index on Identical Tables in Two Different Databases
Date: 2013-07-17 19:50:06
Message-ID: d2c495ac125a4e94acd463a6981136f2@BLUPR08MB166.namprd08.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

I have the same table definition in two different databases on the same computer. When I explain a simple query in both of them, one database uses a sequence scan and the other uses an index scan. If I try to run the Seq Scan version without the where clause restricting the value of uniqueid, it uses all of the memory on my computer and never completes.

How can I get the Seq Scan version to use an index scan?

Explain results - good version:
"GroupAggregate (cost=0.00..173.78 rows=1 width=15)"
" -> Index Scan using pubcoop_ext_idx1 on pubcoop_ext (cost=0.00..173.77 rows=1 width=15)"
" Index Cond: (uniqueid < '000000009'::bpchar)"

Explain results - problem version:
"HashAggregate (cost=13540397.84..13540398.51 rows=67 width=18)"
" -> Seq Scan on pubcoop_ext (cost=0.00..13360259.50 rows=36027667 width=18)"
" Filter: (uniqueid < '000000009'::bpchar)"

Thanks,
Ellen

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message bricklen 2013-07-17 20:11:42 Re: Seq Scan vs Index on Identical Tables in Two Different Databases
Previous Message Xenofon Papadopoulos 2013-07-17 12:18:18 Re: Distributed transactions and asynchronous commit