Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id A22D79FB27F for ; Thu, 11 Jan 2007 14:31:40 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 20972-04 for ; Thu, 11 Jan 2007 14:31:28 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id EEEED9FB284 for ; Thu, 11 Jan 2007 14:31:29 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id l0BIV7x7028141; Thu, 11 Jan 2007 13:31:07 -0500 (EST) To: carlos.reimer@opendb.com.br cc: pgsql-performance@postgresql.org Subject: Re: Improving SQL performance In-reply-to: References: Comments: In-reply-to "Carlos H. Reimer" message dated "Thu, 11 Jan 2007 16:17:06 -0200" Date: Thu, 11 Jan 2007 13:31:07 -0500 Message-ID: <28140.1168540267@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/180 X-Sequence-Number: 22781 "Carlos H. Reimer" writes: > I know that the problem with the following SQL is the "LOG.CODCEP = > ENDE.CODCEP||CODLOG" condition, but what can I > do to improve the performance? Seems the problem is not using an index for tt_log. Do you have an index on tt_log.codcep? If so, maybe you need to cast the result of the concatenation to char(8) to get it to use the index. regards, tom lane