Inserts create new records in reporting table

From: Bret Stern <bret_stern(at)machinemanagement(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Inserts create new records in reporting table
Date: 2022-12-31 07:02:31
Message-ID: 5a52b569-e54c-98f5-9c23-937186ad8477@machinemanagement.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Love the forum,

I'm bringing 100k - 200k of AR transactions into a table from several
separate ERP companies.

As I insert the records, does it make sense to run a trigger event to
build or insert data into

a reporting table (to save generating a query to build the reporting
table later.)

For example, I bring in 120k records which contain invoice dates from
the beginning of time

in the ERP system. (eg; records with dated transactions from 2010...2022)

Conceptual data

[Location][InvoiceDate][Amount]

Dallas        2012-01-09    7500.00
Dallas        2012-11-19    1200.00
Dallas        2012-04-02    500.00
Phoenix       2012-01-03    1200.00
Phoenix        2012-04-12    7500.00

Would it be possible, or would it make sense to create a trigger which
populated another

table like below after each insert...or is is a resource killer..or just
unnecessary, and smarter to create a query

that performs calculated on the fly columns for the dates of invoice?

[Location][InvoiceDate][Amount]    [Jan]            [Feb]     [Mar]    
       [Apr]          [May]             [Jun]      [Jul]         [Aug]
          [Sep]            [Oct]     [Nov]         [Dec]

Dallas         2012-01-09                   7500.00

Dallas 2012-11-19 1200.00

Dallas 2012-04-02 500.00

Phoenix    2012-01-03                    1200.00

Phoenix 2012-04-12 7500.00

Bret

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2022-12-31 08:55:10 Re: Inserts create new records in reporting table
Previous Message Ron 2022-12-30 20:24:33 Re: Exact same output - pg_stat_statements