Re: [PERFORM] Speed of exist

2013-02-19 Thread Bastiaan Olij
Hi Pavel, That is what I've done in this particular case but there are parts where I use exist checks in this way that are very cumbersome to write out like that so I'm hoping there is a way to make the optimizer work with existence checks in this way. Cheers, Bastiaan Olij On 19/02/13 6:39

[PERFORM] Speed of exist

2013-02-18 Thread Bastiaan Olij
Hi All, Hope someone can help me a little bit here: I've got a query like the following: -- select Column1, Column2, Column3 from Table1 where exists (select 1 from Table2 where Table2.ForeignKey = Table1.PrimaryKey) or exists (select 1 from Table3 where Table3.ForeignKey = Table1.PrimaryKey) --

Re: [PERFORM] Speed of exist

2013-02-18 Thread Andy
Limit the sub-queries to 1, i.e. : select 1 from Table2 where Table2.ForeignKey = Table1.PrimaryKey fetch first 1 rows only Andy. On 19.02.2013 07:34, Bastiaan Olij wrote: Hi All, Hope someone can help me a little bit here: I've got a query like the following: -- select Column1, Column2,

Re: [PERFORM] Speed of exist

2013-02-18 Thread Bastiaan Olij
Hi Andy, I've tried that with the same result. One subquery works beautifully, two subqueries with an OR and it starts to do a sequential scan... Thanks, Bastiaan Olij On 19/02/13 6:31 PM, Andy wrote: Limit the sub-queries to 1, i.e. : select 1 from Table2 where Table2.ForeignKey =

Re: [PERFORM] Speed of exist

2013-02-18 Thread Pavel Stehule
2013/2/19 Bastiaan Olij basti...@basenlily.me: Hi Andy, I've tried that with the same result. One subquery works beautifully, two subqueries with an OR and it starts to do a sequential scan... try to rewrite OR to two SELECTs joined by UNION ALL Pavel Thanks, Bastiaan Olij On 19/02/13