Getting most records possibly from an Inner/Left Join

From: Anthony Apollis <anthony(dot)apollis(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Getting most records possibly from an Inner/Left Join
Date: 2023-11-19 11:42:15
Message-ID: CAJyMCY+E52CHeES=3hq=hDXxNy8mpVghx8jUdD2=+GZtJrZ6-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

For sample data in Excel see
https://drive.google.com/file/d/17aOmG-Ynx-6U05wNNrHXJG7iywgCMiuy/view?usp=sharing

(1) The fact table is from SAP.

(2) Dimension Tables are named "B Masked". Please note that none of the
tables had primary keys, I had to bring them in myself. In the Bracs
Mapping tab of this file, there is a column GCoA which is the Account
Number. Then there is BRACS which is the Bracs(source) Account number.
these numbers match the same columns in the Mapping tab of the Cash Flow
Pivoted file.

(3) The Source Data is a combination and shorter version of the Mapping
tab. Column Account match GCoA and BRACS Account match

matches BRACS in the Bracs mapping tab above of the B Masked file.

I noticed some similarities in the different tabs/tables so I denormalised
some tabs/tables. e.g. Region Mapping and Entity Mapping in the same file I
made as 1 table.

Joining on not unique keys is of concern.

(4) Cash Flow file, tab Sap Source is a pivoted table of the Source Data.

(5) The Cash Flow tab is the final reporting structure that must be
replicated in power. Column "G" in this tab is the "Function" column in the
Pivoted tab.

I do left joins to the Fact table and some inner join. Please advise.

The Function column that makes up the bulk of giving meaning to the
figures, most of the detail of this column is left out when I do a join as
seen in Imeta_Bracs_Roll_Up joined to Fact file with SQL code.

I brought in the Mapping table to connect the roll-up table to it as seen
in Imeta_Bracs_Roll_Up joined to Bridge, this query takes. very long to
run. Also, the joins take a lot of memory and some ETL/SSIS tasks may fail.
What would you be bettering in this instance?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Achilleas Mantzios 2023-11-19 13:45:36 Re: Getting most records possibly from an Inner/Left Join
Previous Message Tom Lane 2023-11-17 20:14:06 Re: query plan