[PERFORM] Inefficient query plan

2010-08-22 Thread Jann Röder
I have two tables: A: ItemID (PK), IsssueID (Indexed) B: ItemID (FK), IndexNumber : PK(ItemID, IndexNumber) Both tables have several million columns, but B has much more than A. Now if I run SELECT A.ItemID FROM A, B WHERE A.ItemID = B.itemID AND A.issueID = The query takes extremely long (sev

Re: [PERFORM] Inefficient query plan

2010-08-23 Thread Jann Röder
Am 23.08.10 07:52, schrieb Scott Marlowe: > Also are a.indexid and b.indexid the same type? > You mean ItemID? Fields of the same name are of the same type - so yes. According to the documentation pgsql adds indexes for primary keys automatically so (b.itemID, b.indexNumber) is indexed. Or do you

Re: [PERFORM] Inefficient query plan

2010-08-23 Thread Jann Röder
Am 23.08.10 12:18, schrieb Scott Marlowe: > On Mon, Aug 23, 2010 at 4:15 AM, Jann Röder wrote: >> Am 23.08.10 07:52, schrieb Scott Marlowe: >>> Also are a.indexid and b.indexid the same type? >>> >> >> You mean ItemID? Fields of the same name are of the

Re: [PERFORM] Inefficient query plan

2010-08-23 Thread Jann Röder
Scan using idx_papers_issueid on papers p (cost=0.00..274.53 rows=508 width=16)" " Index Cond: (issueid = 'A1983PW823'::bpchar)" Do you need an EXPLAIN ANALYZE output? Since it takes so long I can't easily post one right now. But maybe I can get one o

Re: [PERFORM] Inefficient query plan

2010-08-24 Thread Jann Röder
I get my result really fast. So what I need now is a way to tell postgres to do it that way automatically. If everything else fails I will have to put that logic into my application in java code, which I don't want to do because then I will also have to remove my constraints so I can delete stuff

Re: [PERFORM] Inefficient query plan

2010-08-24 Thread Jann Röder
(cost=0.00..8838.21 rows=4078 width=16)" "Index Cond: (r.itemid = p.itemid)" So thanks again. I'm starting to grasp the postgres quirks :) Jann Am 24.08.10 15:03, schrieb Jann Röder: > So that took a while... I'm currently running ANALYZE on the > PaperRefere