ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Dealing with a massive Transaction Table

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dealing with a massive Transaction Table

    Assume we have a table called “Transactions”. This table consists of all sales transactions ever recorded in the system. It holds approximately 155 million records. Each night a program runs that reads through EVERY record from the Transactions table and copies each record’s fields and some additional fields from other tables and places them into a new table that we’ll refer to as “New_Transactions”. Please note that the New_Transactions table gets cleared before it’s populated each evening. Thus, they’re currently doing a rebuild of everything each night.

    99% of the time the New_Transactions table is identical to the original Transactions table with the exception of new records from the day prior that exist in the Transactions table. In a perfect world the New_Transactions table wouldn’t get cleared, and only the new records would be appended to the table.

    That catch here is there are times when historical information changes like sales region changes, and these changes need to be incorporated into the New_Transactions table. I also need to ensure that everything from the Transaction table exists in the New_Transactions table and if a record doesn’t exist any longer in the Transactions table, then it also needs to be removed from the New Transactions Table.

    I’d like to hear your thoughts. If you’re asking, “Why are they doing it this way?” It’s not my design, I’ve only been asked to make it run faster as this process takes over 2 hours to run each evening.


  • #2
    Whats about a trigger? Every Time somethings is changed on the big Table a Trigger can inform you.

    GG 2777

    Comment


    • #3
      Why to read all rows?
      Won't you have a column that includes the transaction date/time?
      What if you add an index over this column and then only read the new records written for the previous day?

      Another option could be to add a trigger that immediately copies the record into the new table.

      Comment


      • #4
        Triggers are the perfect answer! Thanks all!

        Comment

        Working...
        X