wildcard makes seq scan on prod db but not in test

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

 



Dear list,

I have a table with a few million rows and this index:
CREATE INDEX bond_item_common_x7 ON bond_item_common ((lower(original_filename)));

There are about 2M rows on bonddump and 4M rows on bond90.

bonddump is on a 8MB RAM machine, bond90 is on a 72MB RAM machine.

The table is analyzed properly both places.

I'm an index hint zealot, but aware of our different stances in the matter. :)

Dropping the wildcard for the like, both databases uses the index.

Is there a way to convince Postgres to try not to do full table scan as much? This is just one of several examples when it happily spends lots of time sequentially going thru tables.

Thanks,
Marcus




psql (9.0.4)
Type "help" for help.

bonddump=# explain analyze          select pic2.objectid
bonddump-#          from bond_item_common pic2
bonddump-#          where
bonddump-# lower(pic2.original_filename) like 'this is a test%' ; QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------
Index Scan using bond_item_common_x7 on bond_item_common pic2 (cost=0.01..8.69 rows=208 width=4) (actual time=26.415..26.415 rows=0 loops=1) Index Cond: ((lower((original_filename)::text) >= 'this is a test'::text) AND (lower((original_filename)::text) < 'this is a tesu'::text))
   Filter: (lower((original_filename)::text) ~~ 'this is a test%'::text)
 Total runtime: 26.519 ms
(4 rows)




psql (9.0.4)
bond90=> explain analyze          select pic2.objectid
bond90->          from bond_item_common pic2
bond90->          where
bond90->              lower(pic2.original_filename) like 'this is a test%' ;
                                                          QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Seq Scan on bond_item_common pic2 (cost=0.00..839226.81 rows=475 width=4) (actual time=10599.401..10599.401 rows=0 loops=1)
   Filter: (lower((original_filename)::text) ~~ 'this is a test%'::text)
 Total runtime: 10599.425 ms
(3 rows)


--
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


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

  Powered by Linux