Re: Speed up the query

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Speed up the query
Дата
Msg-id 1385913725.4005.YahooMailNeo@web162901.mail.bf1.yahoo.com
обсуждение исходный текст
Ответ на Speed up the query  (Hengky Liwandouw <hengkyliwandouw@gmail.com>)
Ответы Re: Speed up the query
Список pgsql-performance
Hengky Liwandouw <hengkyliwandouw@gmail.com> wrote:

> where jualid is not null
> and extract(year from tanggal)='2013')

> But the problem is : when i change the where clause to :
>
> where jualid is not null or returjualid is not null
> and extract(year from tanggal)='2013')
>
> (there is additional or returjualid is not null,) the query needs
> 56 second to display the result.

Before worrying about the run time, I would worry about whether you
are getting the results you expect.  That will be interpreted as:

where jualid is not null
   or (returjualid is not null and extract(year from tanggal) = '2013')

... not:

where (jualid is not null or returjualid is not null)
  and extract(year from tanggal) = '2013'
AND has higher priority than OR; so if you want to limit by year
from tanggal even when jualid is not null, you must use
parentheses.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


В списке pgsql-performance по дате отправления:

Предыдущее
От: Hengky Liwandouw
Дата:
Сообщение: Re: Speed up the query
Следующее
От: Hengky Lie
Дата:
Сообщение: Re: Speed up the query