X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id AC7F69FA5C3 for ; Tue, 4 Jul 2006 13:00:16 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 83993-01 for ; Tue, 4 Jul 2006 13:00:08 -0300 (ADT) 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 A645B9FA4A8 for ; Tue, 4 Jul 2006 13:00:07 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id a2so1890488ugf for ; Tue, 04 Jul 2006 09:00:03 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=HKl4Wx9NDCiTVSSMiqPLsBPNdhI03FgBlK725vWtBs4BjnIrL436BjWpiwi6I26S8sBoEANQiVE14FfMg1mo9wdG917MZLPUZ+eeCtNdvojukUJADYUmZbB8CYUtUmNumADbt36Lo1gVyL1Xl/t/5oGvdUkW3r81S27hkEWrso4= Received: by 10.67.101.10 with SMTP id d10mr6733519ugm; Tue, 04 Jul 2006 09:00:03 -0700 (PDT) Received: by 10.66.251.18 with HTTP; Tue, 4 Jul 2006 09:00:02 -0700 (PDT) Message-ID: Date: Tue, 4 Jul 2006 20:00:02 +0400 From: Luckys To: pgsql-performance@postgresql.org Subject: how to tune this query. MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_72450_1574529.1152028802875" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.462 tagged_above=0 required=5 tests=BAYES_00, DNS_FROM_RFC_ABUSE, FROM_LOCAL_NOVOWEL, HTML_MESSAGE, SPF_PASS, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200607/18 X-Sequence-Number: 19878 ------=_Part_72450_1574529.1152028802875 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi all, I got this query, I'm having indexes for PropertyId and Dates columns across all the tables, but still it takes ages to get me the result. What indexes would be proposed on this, or I'm helpless? FROM STG_Property a FULL OUTER JOIN STG_PropConfirmedLogs b ON (a.PropertyId = b.PropertyId AND a.p_LastModified = b.p_Modified_Date ) FULL OUTER JOIN STG_PropConnectionFeesLogs c ON ((a.PropertyId = c.PropertyId AND a.p_LastModified = c.p_ChangedOn) OR (b.PropertyId = c.PropertyId AND b.p_Modified_Date = c.p_ChangedOn)) FULL OUTER JOIN STG_PropDeletedLogs d ON ((a.PropertyId = d.PropertyId AND a.p_LastModified = d.p_DeletedOn) OR (b.PropertyId = d.PropertyId AND b.p_Modified_Date = d.p_DeletedOn) OR (c.PropertyId = d.PropertyId AND c.p_ChangedOn = d.p_DeletedOn)) FULL OUTER JOIN STG_PropFEWALogs e ON ((a.PropertyId = e.PropertyId AND a.p_LastModified = e.p_Modified_Date) OR (b.PropertyId = e.PropertyId AND b.p_Modified_Date = e.p_Modified_Date) OR (c.PropertyId = e.PropertyId AND c.p_ChangedOn = e.p_Modified_Date) OR (d.PropertyId = e.PropertyId AND d.p_DeletedOn = e.p_Modified_Date)) FULL OUTER JOIN STG_PropInSewerNetworkLogs f ON ((a.PropertyId = f.PropertyId AND a.p_LastModified = f.p_Modified_Date) OR (b.PropertyId = f.PropertyId AND b.p_Modified_Date = f.p_Modified_Date) OR (c.PropertyId = f.PropertyId AND c.p_ChangedOn = f.p_Modified_Date) OR (d.PropertyId = f.PropertyId AND d.p_DeletedOn = f.p_Modified_Date) OR (e.PropertyId = f.PropertyId AND e.p_Modified_Date = f.p_Modified_Date)) FULL OUTER JOIN STG_PropTypeLogs g ON ((a.PropertyId = g.PropertyId AND a.p_LastModified = g .p_LastModified) OR (b.PropertyId = g.PropertyId AND b.p_Modified_Date = g .p_LastModified) OR (c.PropertyId = g.PropertyId AND c.p_ChangedOn = g.p_LastModified) OR (d.PropertyId = g.PropertyId AND d.p_DeletedOn = g.p_LastModified) OR (e.PropertyId = g.PropertyId AND e.p_Modified_Date = g .p_LastModified) OR (f.PropertyId = g.PropertyId AND f.p_Modified_Date = g .p_LastModified)) -- Luckys ------=_Part_72450_1574529.1152028802875 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Hi all,
I got this query, I'm having indexes for PropertyId and Dates columns across all the tables, but still it takes ages to get me the result. What indexes would be proposed on this, or I'm helpless?
 
FROM  STG_Property a
 
  FULL OUTER JOIN
    STG_PropConfirmedLogs b
    ON (a.PropertyId = b.PropertyId AND a.p_LastModified = b.p_Modified_Date)
 
  FULL OUTER JOIN
    STG_PropConnectionFeesLogs c
    ON ((a.PropertyId = c.PropertyId AND a.p_LastModified = c.p_ChangedOn)
    OR  (b.PropertyId = c.PropertyId AND b.p_Modified_Date = c.p_ChangedOn))
 
  FULL OUTER JOIN
    STG_PropDeletedLogs d
    ON ((a.PropertyId = d.PropertyId AND a.p_LastModified = d.p_DeletedOn)
    OR  (b.PropertyId = d.PropertyId AND b.p_Modified_Date = d.p_DeletedOn)
    OR  ( c.PropertyId = d.PropertyId AND c.p_ChangedOn = d.p_DeletedOn))
 
  FULL OUTER JOIN
    STG_PropFEWALogs e
    ON ((a.PropertyId = e.PropertyId AND a.p_LastModified = e.p_Modified_Date)
    OR  (b.PropertyId = e.PropertyId AND b.p_Modified_Date = e.p_Modified_Date) OR  (c.PropertyId = e.PropertyId AND c.p_ChangedOn = e.p_Modified_Date)
    OR  (d.PropertyId = e.PropertyId AND d.p_DeletedOn = e.p_Modified_Date))
 
  FULL OUTER JOIN
    STG_PropInSewerNetworkLogs f
    ON ((a.PropertyId = f.PropertyId AND a.p_LastModified = f.p_Modified_Date)
    OR  (b.PropertyId = f.PropertyId AND b.p_Modified_Date = f.p_Modified_Date)
    OR   (c.PropertyId = f.PropertyId AND c.p_ChangedOn = f.p_Modified_Date)
    OR  (d.PropertyId = f.PropertyId AND d.p_DeletedOn = f.p_Modified_Date)
    OR  (e.PropertyId = f.PropertyId AND e.p_Modified_Date = f.p_Modified_Date))   FULL OUTER JOIN
    STG_PropTypeLogs g
    ON ((a.PropertyId = g .PropertyId AND a.p_LastModified = g.p_LastModified)
    OR  (b.PropertyId = g.PropertyId AND b.p_Modified_Date = g.p_LastModified)
    OR  (c.PropertyId = g.PropertyId AND c.p_ChangedOn = g.p_LastModified)
    OR  (d.PropertyId = g.PropertyId AND d.p_DeletedOn = g.p_LastModified)
    OR  (e.PropertyId = g.PropertyId AND e.p_Modified_Date = g.p_LastModified)
    OR  (f.PropertyId = g.PropertyId AND f.p_Modified_Date = g.p_LastModified))
 
-- Luckys
------=_Part_72450_1574529.1152028802875--