Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 1E67E2E3303 for ; Tue, 11 Dec 2007 15:46:46 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 08827-01-3 for ; Tue, 11 Dec 2007 15:46:34 -0400 (AST) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.234]) by postgresql.org (Postfix) with ESMTP id 4502A2E30D7 for ; Tue, 11 Dec 2007 15:46:33 -0400 (AST) Received: by wr-out-0506.google.com with SMTP id 58so1903867wri for ; Tue, 11 Dec 2007 11:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=W3+H65CkgFA+YWbhOqINRsN8S0sg7PW+JLJFAb9gADI=; b=A4z5Q2WZ80kC4A6br2KzwhYy3A2wVK4JAR53Zym1SC28x8p/stzfVVmGSkYkeg9dfPXSCHzvNJvOpmO+qB7W7GZFtEWYRzVxI1UpGFxpNyGTL+X5IVWmOZMD+5j86WOZkDoR/jAwuXvONf5Wf5B6pO2ytsOcqLJ25wTQ89sfPJs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=caA2TEDuril0SThicPPWTDNjfBF+6zh0W6/mXmkOy+rR+xihk4T6iJLVu1iQnIaIDaTEyfNm8pfJ0pJSvUDNEJjctiHJHzsEGiwgpK+097yfQNtBxCtLlxX18y27WQ/+J8mPhpJJnT1aNOuVJyOmFA5v4qJ9WD/YCv2rLSzQPKw= Received: by 10.78.204.7 with SMTP id b7mr9131481hug.1197402387386; Tue, 11 Dec 2007 11:46:27 -0800 (PST) Received: by 10.78.35.7 with HTTP; Tue, 11 Dec 2007 11:46:27 -0800 (PST) Message-ID: <162867790712111146x35f547c0pc01fcf1aa167e0e5@mail.gmail.com> Date: Tue, 11 Dec 2007 20:46:27 +0100 From: "Pavel Stehule" To: "Gerry Reno" Subject: Re: join on three tables is slow Cc: pgsql-sql@postgresql.org In-Reply-To: <475ED469.5080906@verizon.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <475C96EA.6090002@verizon.net> <475CC478.7010102@Sheeky.Biz> <475E111B.6060203@verizon.net> <162867790712102200m2144573bw7447e0eff6720d55@mail.gmail.com> <475E8F6A.4030004@verizon.net> <162867790712110655o2cf99bf1n9acf6b440d726440@mail.gmail.com> <475ED469.5080906@verizon.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/56 X-Sequence-Number: 29748 Hello 1) increase statistics on res_partner_address.type (about 100) alter table ... ALTER [ COLUMN ] column SET STATISTICS integer do analyze, and look again on plans. There are difference -> Seq Scan on res_partner_address a (cost=0.00..88.40 rows=16 width=552) (actual time=0.106..3.521 rows=559 loops=510) Filter: ((("type")::text = 'default'::text) OR ("type" IS NULL)) 2) I thing so index on res_partner.addr can help or use better column for identification (varchar isn't best) and partial index rep_partner_address.type is 'default' or resp_partner_address.type is null. Regards Pavel Stehule