Seq Scan vs Index on Identical Tables in Two Different Databases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux