[PERFORM] Inner join on two OR conditions dont use index

2005-05-25 Thread Jocelyn Turcotte
Hi all i dont know if this is normal, but if yes i would like to know why and how I could do it another way other than using unions. (I tried on postgresql 7.4 and 8.0.3, made my vacuum analyse just before) Here is my simple query: select * from rt_node n, rt_edge e where node_id = 2 and

Re: [PERFORM] Inner join on two OR conditions dont use index

2005-05-25 Thread John A Meinel
Jocelyn Turcotte wrote: Hi all i dont know if this is normal, but if yes i would like to know why and how I could do it another way other than using unions. The only thing that *might* work is if you used an index on both keys. So if you did: CREATE INDEX rt_edge_start_end_node ON

Re: [PERFORM] Inner join on two OR conditions dont use index

2005-05-25 Thread Jocelyn Turcotte
Thanks John it dont seems to work, but in my context I only needed data from the rt_node table so I tried this: select * from rt_node n where node_id = 2 and exists (select edge_id from rt_edge where start_node_id = n.node_id or end_node_id = n.node_id) and it gave me this plan (even if I

Re: [PERFORM] Inner join on two OR conditions dont use index

2005-05-25 Thread Tom Lane
Jocelyn Turcotte [EMAIL PROTECTED] writes: But if I plug another condition with a OR like this: select * from rt_node n, rt_edge e where node_id = 2 and (e.start_node_id = n.node_id or e.end_node_id = n.node_id); I get this plan, it stop using the index!: I'm afraid you're stuck with