Query plan and sub-queries

Поиск
Список
Период
Сортировка
От Steve Heaven
Тема Query plan and sub-queries
Дата
Msg-id 3.0.1.32.20000808122212.00bb1c2c@mail.thornet.co.uk
обсуждение исходный текст
Ответы List funnies ?  (Steve Heaven <steve@thornet.co.uk>)
Список pgsql-general
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

В списке pgsql-general по дате отправления:

Предыдущее
От: "Len Morgan"
Дата:
Сообщение: Fw: pg_dump help -- Problem Fixed -- Thank you all!!!
Следующее
От: "Robert D. Nelson"
Дата:
Сообщение: RE: pg_dump help