When the WHERE clause includes a sub query the query plan seems to ignore
indexes.
See the examples below.
Table R1684 has one column, stockno, which is the same type as the stockno
in the books_fti table. There is no index on R1684.
In the first case the index on books_fti(stockno) is not used but in the
second case it is.
=============================== Query 1
=======================================
explain select * from books_fti where stockno in (select stockno from R1684);
Seq Scan on books_fti (cost=79300.27 rows=1024705 width=160)
SubPlan
-> Seq Scan on r1684 (cost=43.00 rows=1000 width=12)
================================ Query 2
=======================================
explain select * from books_fti where stockno in
('0815171161','1857281012','0419251901');
Index Scan using allbooks_isbn, allbooks_isbn, allbooks_isbn on books_fti
(cost
=6.15 rows=5 width=160)
--
thorNET - Internet Consultancy, Services & Training
Phone: 01454 854413
Fax: 01454 854412
http://www.thornet.co.uk