Skip site navigation (1) Skip section navigation (2)

Re: Can Postgres use an INDEX over an OR?

From: Robert James <srobertjames(at)gmail(dot)com>
To: Chris <dmagick(at)gmail(dot)com>
Cc: Віталій Тимчишин <tivv00(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Can Postgres use an INDEX over an OR?
Date: 2009-07-20 13:25:48
Message-ID: (view raw or whole thread)
Lists: pgsql-performance
Query is:
select * from dict
 word in (select substr('moon', 0, generate_series(3,length('moon')))) --
this is my X above
 OR word like 'moon%' -- this is my Y above

dict is indexed on word
2009/7/20 Chris <dmagick(at)gmail(dot)com>

> 2009/7/20 Robert James <srobertjames(at)gmail(dot)com <mailto:
> srobertjames(at)gmail(dot)com>>
>    Hi. I notice that when I do a WHERE x, Postgres uses an index, and
>    when I do WHERE y, it does so as well, but when I do WHERE x OR y,
>    it doesn't. Why is this so?
> What Robert didn't post was his query, see
> which makes it a lot harder to 'optimize' since they aren't straight
> forward conditions.

In response to

pgsql-performance by date

Next:From: Craig JamesDate: 2009-07-20 14:29:13
Subject: Used computers?
Previous:From: Robert JamesDate: 2009-07-20 13:23:46
Subject: Re: Fastest char datatype

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group