Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 1EF989FB27B for ; Thu, 11 Jan 2007 17:15:05 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 74611-10 for ; Thu, 11 Jan 2007 17:14:47 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from server.linux27.com (server.linux27.com [72.232.77.42]) by postgresql.org (Postfix) with ESMTP id 9F51D9FB27A for ; Thu, 11 Jan 2007 17:14:50 -0400 (AST) Received: from [201.67.131.242] (helo=PC1) by server.linux27.com with esmtpa (Exim 4.63) (envelope-from ) id 1H57G9-0006Cx-2a; Thu, 11 Jan 2007 19:14:53 -0200 Reply-To: From: "Carlos H. Reimer" To: "Tom Lane" Cc: Subject: RES: Improving SQL performance Date: Thu, 11 Jan 2007 19:14:51 -0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 In-reply-to: <28140.1168540267@sss.pgh.pa.us> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.linux27.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - opendb.com.br X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/187 X-Sequence-Number: 22788 Yes, I do have an index on tt_log.codcep. Indexes I´ve on both tables: tt_end Indexes: "pk_end" PRIMARY KEY, btree (filcli, codcli, codfil, numend) "ak_end_numdoc" UNIQUE, btree (numdoc) "i_fk_end_darc" btree (codarc, tiparc) "i_fk_end_dend" btree (tipend) "i_fk_end_dfil" btree (codfil) "i_fk_end_dreg" btree (regiao) "i_fk_end_mun" btree (codcid) tt_log Indexes: "i_fk_log_bai" btree (codbai) "i_lc_log_codcep" btree (codcep) Any clue? Thanks! Reimer > -----Mensagem original----- > De: Tom Lane [mailto:tgl@sss.pgh.pa.us] > Enviada em: quinta-feira, 11 de janeiro de 2007 16:31 > Para: carlos.reimer@opendb.com.br > Cc: pgsql-performance@postgresql.org > Assunto: Re: [PERFORM] Improving SQL performance > > > "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 > >