Seq Scan vs Index on Identical Tables in Two Different Databases - Mailing list pgsql-performance

From Ellen Rothman
Subject Seq Scan vs Index on Identical Tables in Two Different Databases
Date
Msg-id d2c495ac125a4e94acd463a6981136f2@BLUPR08MB166.namprd08.prod.outlook.com
Whole thread Raw
Responses Re: Seq Scan vs Index on Identical Tables in Two Different Databases
Re: Seq Scan vs Index on Identical Tables in Two Different Databases
Re: Seq Scan vs Index on Identical Tables in Two Different Databases
List 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

pgsql-performance by date:

Previous
From: Xenofon Papadopoulos
Date:
Subject: Re: Distributed transactions and asynchronous commit
Next
From: bricklen
Date:
Subject: Re: Seq Scan vs Index on Identical Tables in Two Different Databases