| От | Kyle Bateman |
|---|---|
| Тема | Re: Index not used in functions in 7.0? |
| Дата | |
| Msg-id | 39218FB6.450431A8@actarg.com обсуждение исходный текст |
| Ответ на | Index not used in functions in 7.0? (Kyle Bateman <kyle@actarg.com>) |
| Список | pgsql-sql |
mig@utdt.edu wrote:
> I am probably completely wrong, but at least it will be short ...
>
> Could it be that
> select sum(tquant)
> from mtr_reg
> where to_proj = $2
> and pnum = $1
> and (status = 'clsd' or status = 'open' or status = 'prip')
> ;
> makes it harder for the optimizer due to the ORs, and that
> select sum(tquant)
> from mtr_reg
> where to_proj = $2
> and pnum = $1
> and status in ('clsd','open','prip')
> --- last line changed
> ;
> would produce a better cost estimate?
>
> Miguel Sofer
Thanks for the input. Your point might be correct, but my results are
the same regardless of the clause attached to the status field. In one
of my tests, the query simply had "and status = 'clsd'." The issue here
is that a sequential scan is being chosen over an indexed scan when the
query is run from within a function.
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера