Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vtgk7-0006wQ-Lu for pgsql-performance@arkaria.postgresql.org; Thu, 19 Dec 2013 16:46:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Vtgk6-0003Yr-Mh for pgsql-performance@arkaria.postgresql.org; Thu, 19 Dec 2013 16:46:34 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VtMiM-0008Jz-N1 for pgsql-performance@postgresql.org; Wed, 18 Dec 2013 19:23:26 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VtMiK-00011J-3o for pgsql-performance@postgresql.org; Wed, 18 Dec 2013 19:23:26 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1VtMiH-0003SN-Qw for pgsql-performance@postgresql.org; Wed, 18 Dec 2013 11:23:22 -0800 Date: Wed, 18 Dec 2013 11:23:21 -0800 (PST) From: "kolszew73@gmail.com" To: pgsql-performance@postgresql.org Message-ID: <1387394601821-5783927.post@n5.nabble.com> In-Reply-To: <1386746318622-5782822.post@n5.nabble.com> References: <52A7A428.8070104@gmail.com> <1386746318622-5782822.post@n5.nabble.com> Subject: Re: Problem with slow query with WHERE conditions with OR clause on primary keys MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 1.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 Thanx for your answer My example is trivial because i want to show strange (for me) postgres behavior with dealing with primary keys (extreme example), in real situation user put search condition e.g. "Panas" and this generates query ... where gd.other_code like 'Panas%' OR g.code like 'Panas%' .. both columns has very good indexes and selectivity for "like 'Panas%'" ... I have experience from Oracle with this type of queries, and Oracle have no problem with it, executes select on index on other_code from gd and join g in next step executes select on index on code from g and join gd and this two results are connected in last step (like union) very fast on minimal cost and in my opinion read whole huge tables only for 10 rows in result where conditions are very good ... is strange -- View this message in context: http://postgresql.1045698.n5.nabble.com/Problem-with-slow-query-with-WHERE-conditions-with-OR-clause-on-primary-keys-tp5782803p5783927.html Sent from the PostgreSQL - performance mailing list archive at Nabble.com. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance