Re: [GENERAL] Or selection on index versus union

2005-10-05 Thread Jim C. Nasby
On Wed, Oct 05, 2005 at 11:13:58AM +0200, [EMAIL PROTECTED] wrote: > On Tuesday 04 October 2005 23:08, Michael Fuhr wrote: > > On Tue, Oct 04, 2005 at 09:32:41PM +0200, [EMAIL PROTECTED] wrote: > > > I've got a table with an index, let's call it fase. > > > > > > The following query is fine: 'selec

Re: [GENERAL] Or selection on index versus union

2005-10-05 Thread Douglas McNaught
[EMAIL PROTECTED] writes: > PS We still have to be careful how to formulate conditions: > > where fase in ('1','2') > > is ok, and uses the index, but the logically identical: > > where position(fase in '12') >= 1 > > does a sequential scan. Right, you would need a functional index to fix that.

Re: [GENERAL] Or selection on index versus union

2005-10-05 Thread han . holl
On Tuesday 04 October 2005 23:08, Michael Fuhr wrote: > On Tue, Oct 04, 2005 at 09:32:41PM +0200, [EMAIL PROTECTED] wrote: > > I've got a table with an index, let's call it fase. > > > > The following query is fine: 'select something from table where fase = > > '1'; > > > > However, this is disast

Re: [GENERAL] Or selection on index versus union

2005-10-04 Thread han . holl
On Tuesday 04 October 2005 22:26, [EMAIL PROTECTED] wrote: > Just a guess but have you tried using an in clause? > > select something from table where fase in ('1' , '2'); > Not surprisingly, this also does a sequential scan on the table. (It would be _very_ diffcult to see that this is a union,

Re: [GENERAL] Or selection on index versus union

2005-10-04 Thread Michael Fuhr
On Tue, Oct 04, 2005 at 09:32:41PM +0200, [EMAIL PROTECTED] wrote: > I've got a table with an index, let's call it fase. > > The following query is fine: 'select something from table where fase = '1'; > > However, this is disastrously slow: > select something from table where fase = '1' or fase

Re: [GENERAL] Or selection on index versus union

2005-10-04 Thread kevin . kempter
Just a guess but have you tried using an in clause? select something from table where fase in ('1' , '2'); On Tuesday 04 October 2005 13:32, [EMAIL PROTECTED] wrote: > Hello > > I've got a table with an index, let's call it fase. > > The following query is fine: 'select something from table w

[GENERAL] Or selection on index versus union

2005-10-04 Thread han . holl
Hello I've got a table with an index, let's call it fase. The following query is fine: 'select something from table where fase = '1'; However, this is disastrously slow: select something from table where fase = '1' or fase = '2'; The reason is that the query planner decides to ignore the inde