Re: Trying to get postgres to use an index

From: <mike(dot)wertheim(at)linkify(dot)com>
To: <joelstevenson(at)mac(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Trying to get postgres to use an index
Date: 2004-11-06 22:50:14
Message-ID: 1726.12.134.204.65.1099781414.squirrel@mail.linkify.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Uwe C. Schroeder 2004-11-06 23:13:22 SQL question
Previous Message Joel Stevenson 2004-11-06 22:17:19 Re: Trying to get postgres to use an index