Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vn9TL-0008O3-HD for pgsql-performance@arkaria.postgresql.org; Sun, 01 Dec 2013 16:02:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Vn9TK-00018h-Mk for pgsql-performance@arkaria.postgresql.org; Sun, 01 Dec 2013 16:02:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vn9TI-00017r-6t for pgsql-performance@postgresql.org; Sun, 01 Dec 2013 16:02:12 +0000 Received: from nm33-vm8.bullet.mail.bf1.yahoo.com ([72.30.238.198]) by magus.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Vn9TE-0006Gh-30 for pgsql-performance@postgresql.org; Sun, 01 Dec 2013 16:02:11 +0000 Received: from [98.139.212.153] by nm33.bullet.mail.bf1.yahoo.com with NNFMP; 01 Dec 2013 16:02:05 -0000 Received: from [98.139.212.217] by tm10.bullet.mail.bf1.yahoo.com with NNFMP; 01 Dec 2013 16:02:05 -0000 Received: from [127.0.0.1] by omp1026.mail.bf1.yahoo.com with NNFMP; 01 Dec 2013 16:02:05 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 822129.58440.bm@omp1026.mail.bf1.yahoo.com Received: (qmail 29384 invoked by uid 60001); 1 Dec 2013 16:02:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s1024; t=1385913725; bh=tNYyI2y6yjfF++gerqLF6EBK5hxcT/XiZtCAUSnHNqE=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=KpFAz1jaueywqw+0ShHmoJz8xx+Os9HLP12Wy4OMuaqFfghWBGkKGqN8V/Pg7eNsfNejOZ/bKIjm22JVcH7KgkEnxAfPW1le1Uk6rZ/MSl/nCTQJh+Nh6Zi4OogIxLbk0TYPRij6D/8yugkH/MWCO4H/y8Tpy803yIB2aVAVlmQ= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=ymail.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=J6RMKvjNu6ZUaKsHVSTba/TJ9q4dDy9ZarWbCdZcvnrDIN1hWXHxnRQ+tYMOhtsM57RO4M3mav1Y34IMAdqqxEztIyoBxQObeLTa0yFLSygZsnxGu6nB/qyUnj+fPKtHPHfTKZSkHjwJ4uuj7Rbv+yuxWZ8zoAfU+OvAAMZQ7k0=; X-YMail-OSG: UPixhakVM1n7huB74rZ_zuj0wwsuIgJppA1qk3GVheg_TwV oRN8Hbz.yFwp5fe.kcDX2jMyuMM7R6lSLRVHNn2q_Xu6KsGGU1T609wr3CCO aBMSPU8.TU0GBFPGKLfoSx7QMfTgmayHTTJ3eTDpX4QzTqE8mBhgM5XkVElr .Z8fhkejGjoFzx.exZvfToxOoNneXyof5d8W2fSOqKk2CgsSt45V6KDUQsg4 FHncB1avWI5P7BNUXy3n.qH_19zMafuwu.gRD3EUdPhEZsy4iV9uCCPnnQ14 zGc5pS4ecXzEtMmrKgpzB6qOxUVVaaMhXxYNf1h1Bdf0AF85JgMBrjDqbIkR 6UVXW3HosLtvCn.L3g178VE9_Kz3ZML_5xzdZV_gMl_3PsrgNw43P0pAmO1T OMKyo1r6mq.qFjoYn1keBiG432.ML8CukAy7W7klD6Ua5CSRaI.Ex1zQZjB1 W_xxH1a_10QKfiDws_KYclDZVMX5qlc664.Jbc4_SRHlASobddEZW.aewm6e 7ORzklnRUqQH8yxT20D.isDx1polQKC0ERinTCwqCM5WFltDk2YwDlGJow1L DtNPOBRdDyIERl6do09UDet0ONsX1.rlLERN1vfra Received: from [76.255.18.237] by web162901.mail.bf1.yahoo.com via HTTP; Sun, 01 Dec 2013 08:02:05 PST X-Rocket-MIMEInfo: 002.001, SGVuZ2t5IExpd2FuZG91dyA8aGVuZ2t5bGl3YW5kb3V3QGdtYWlsLmNvbT4gd3JvdGU6Cgo.IHdoZXJlIGp1YWxpZCBpcyBub3QgbnVsbCAKPiBhbmQgZXh0cmFjdCh5ZWFyIGZyb20gdGFuZ2dhbCk9JzIwMTMnKQoKPiBCdXQgdGhlIHByb2JsZW0gaXMgOiB3aGVuIGkgY2hhbmdlIHRoZSB3aGVyZSBjbGF1c2UgdG8gOgo.Cj4gd2hlcmUganVhbGlkIGlzIG5vdCBudWxsIG9yIHJldHVyanVhbGlkIGlzIG5vdCBudWxsCj4gYW5kIGV4dHJhY3QoeWVhciBmcm9tIHRhbmdnYWwpPScyMDEzJykKPgo.ICh0aGVyZSABMAEBAQE- X-Mailer: YahooMailWebService/0.8.167.602 References: Message-ID: <1385913725.4005.YahooMailNeo@web162901.mail.bf1.yahoo.com> Date: Sun, 1 Dec 2013 08:02:05 -0800 (PST) From: Kevin Grittner Reply-To: Kevin Grittner Subject: Re: Speed up the query To: Hengky Liwandouw , "pgsql-performance@postgresql.org" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Hengky Liwandouw wrote: > where jualid is not null=20 > and extract(year from tanggal)=3D'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)=3D'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.=A0 That will be interpreted as: where jualid is not null =A0=A0 or (returjualid is not null and extract(year from tanggal) =3D '2013= ') ... not: where (jualid is not null or returjualid is not null) =A0 and extract(year from tanggal) =3D '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 --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance