Re: Trying to get postgres to use an index
| От | |
|---|---|
| Тема | Re: Trying to get postgres to use an index |
| Дата | |
| Msg-id | 1726.12.134.204.65.1099781414.squirrel@mail.linkify.com обсуждение исходный текст |
| Ответ на | Re: Trying to get postgres to use an index (Joel Stevenson <joelstevenson@mac.com>) |
| Ответы |
Re: Trying to get postgres to use an index
|
| Список | pgsql-general |
> I'm not a SQL guru by any stretch but would a
> constrained sub-select be appropriate here?
> Well, you're joining the entire two tables, so yes, the seq scan might
> be faster.
My mistake! When composing the email to state the problem, I accidentally
gave a wrong version of the join query.
Here is the corrected version, which still has the sequential scan...
explain select notificationID from NOTIFICATION n, ITEM i where n.itemID
= i.itemID and i.projectID = 12;
QUERY PLAN
---------------------------------------------------------------------------
-----------------------
Hash Join (cost=2237.54..15382.32 rows=271 width=44)
Hash Cond: ("outer".itemid = "inner".itemid)
-> Seq Scan on notification n (cost=0.00..12023.71 rows=223671
width=48)
-> Hash (cost=2235.31..2235.31 rows=895 width=4)
-> Index Scan using item_ix_item_4_idx on item i
(cost=0.00..2235.31 rows=895width=4)
Index Cond: (projectid = 12)
В списке pgsql-general по дате отправления: