Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 460989FA646 for ; Mon, 16 Oct 2006 18:07:21 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 45804-03 for ; Mon, 16 Oct 2006 21:07:13 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.174]) by postgresql.org (Postfix) with ESMTP id B92C19FA4B4 for ; Mon, 16 Oct 2006 18:07:12 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id 30so839877ugc for ; Mon, 16 Oct 2006 14:07:11 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=s13L994WIH32wdJyix8byzSIsB+ryAsB39FJ8WehSrO+O9n2eAdsDZeNhT2lr92AmpYKkj8ZId7HanE9tgseNJgmkBeRPBAifT1nO4f42i1QCPM8BIWv14E1KTlbLwjd6BcCLFk5tWB8H11n9lH79OzS5M75oY7f94gUb4DYRdw= Received: by 10.78.151.15 with SMTP id y15mr8276847hud; Mon, 16 Oct 2006 14:07:11 -0700 (PDT) Received: by 10.78.35.18 with HTTP; Mon, 16 Oct 2006 14:07:09 -0700 (PDT) Message-ID: Date: Mon, 16 Oct 2006 17:07:11 -0400 From: "Merlin Moncure" To: "Carlo Stonebanks" Subject: Re: Performance Optimization for Dummies 2 - the SQL Cc: pgsql-performance@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1160153623.6181.13.camel@state.g2switchworks.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.199 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, SPF_PASS X-Spam-Level: X-Archive-Number: 200610/306 X-Sequence-Number: 21435 On 10/15/06, Carlo Stonebanks wrote: > that contains full address data > */ > select > f.facility_id, > null as facility_address_id, > null as address_id, > f.facility_type_code, > f.name, > null as address, > f.default_city as city, > f.default_state_code as state_code, > f.default_postal_code as postal_code, > f.default_country_code as country_code, > null as parsed_unit > from > mdx_core.facility as f > left outer join mdx_core.facility_address as fa > on fa.facility_id = f.facility_id > where > facility_address_id is null > and f.default_country_code = 'US' > and (f.default_postal_code = '14224-1945' or f.default_postal_code = > '14224') what is the facility_address_id is null all about? remove it since you hardcode it to true in select. you have a two part part key on facility(country code, postal code), right? merlin