Thanks Kevin. You are absolutely right. I should use parentheses, it is what i want for the query to do.
It also increasing processing time to 5.444 seconds. Should be okay i think.On Sun, Dec 1, 2013 at 11:02 PM, Kevin Grittner <kgrittn@xxxxxxxxx> wrote:
Hengky Liwandouw <hengkyliwandouw@xxxxxxxxx> wrote:
> where jualid is not null
> and extract(year from tanggal)='2013')
> But the problem is : when i change the where clause to :Before worrying about the run time, I would worry about whether you
>
> 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.
are getting the results you expect. That will be interpreted as:
or (returjualid is not null and extract(year from tanggal) = '2013')
where jualid is not null
... 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