Subscribe to Posts by Email

Subscriber Count

    701

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

Quick Question : Finding Transactions on a Table

Folks! this subject line may sound silly, but most of us really think how for a moment.

  • Business Requirement is some want to add a column to high volatile table, So they want to understand,
  • Does it cause issue as its high volatile and access by Website?
  • What is the best time to add a column if so it can issue?
  • What is alternate method to minimise the impact if any?

Ans 1: You can add a column, that's not an issue.

Ans2: Adding a column to highly volatile table will not have any impact unless if there are transactions running and uncommitted your DDL may wait and complete thereafter. There's a caveat here, adding a column with null will complete quickly than adding a column with some default value. The logic behind is the new column value must be updated in all the old rows and if the table is huge it will take time and eventually your transactions may piled up as such DDL lock will protect the transactions to be start.

   

Ans3: Best time to add a column? First find how many transactions happening on that table and if audit enabled find when was least transactions happens

SQL> select * from dba_tab_modifications where table_name in ('XXXXXXXXXXXXXXX');

SCHEMA             TABLE                          INSERTS UPDATES DELETES

PORTAL             XXXXXXXXXXXXXXXXXXXX           16415   16415    9964 

Then, Find from audit trail at what time most of the transactions fired on those tables. ( I am using xml auditing hence v$xml_audit_trail , you can use DBA_AUDIT_TRAIL instead), see at 04AM have very less transactions on the table. Establish a pattern of each day then find out when is the less transactional time for that table.

SQL> select object_name,to_char(EXTENDED_TIMESTAMP,'DD-MON-YY HH24'),count(*) from v$xml_audit_trail  where object_name in ('XXXXXXXXXXXXXXX') group by object_name,to_char(EXTENDED_TIMESTAMP,'DD-MON-YY HH24');

TABLENAME                            DATE HR            Count

--------------------------------  -----------     ---------

XXXXXXXXXXXXXXXXXXXXXXXX10-AUG-16 22483

XXXXXXXXXXXXXXXXXXXXXXXX10-AUG-16 23626

XXXXXXXXXXXXXXXXXXXXXXXX11-AUG-16 00736

XXXXXXXXXXXXXXXXXXXXXXXX11-AUG-16 01962

XXXXXXXXXXXXXXXXXXXXXXXX11-AUG-16 02183

XXXXXXXXXXXXXXXXXXXXXXXX11-AUG-16 03332

XXXXXXXXXXXXXXXXXXXXXXXX11-AUG-16 0466

XXXXXXXXXXXXXXXXXXXXXXXX11-AUG-16 05333

XXXXXXXXXXXXXXXXXXXXXXXX11-AUG-16 07162

XXXXXXXXXXXXXXXXXXXXXXXX11-AUG-16 0862

XXXXXXXXXXXXXXXXXXXXXXXX11-AUG-16 09894

 

XXXXXXXXXXXXXXXXXXXXXXXX11-AUG-16 10717

ANS 4: Alternative method? for Adding a column without impact? Scratching my head really 🙂 , Do you know any? Apart from keeping a replicated table and rename (still it will lock the table)

Geek DBA

3 comments to Quick Question : Finding Transactions on a Table

  • vijay

    Hi,

    Can we initially add null value and later update the table(in bulk batches) with default.

    Other method is to use dbms_redefinition. The only lock time will be during rename and that should be very less when compared to actually adding column to original table.

    • Geek DBA

      Hi Vijay,

      Thanks, yes thats what we did, null value and then added column from app code in insert statement as we dont want to have any value in old rows. That saved a lot.

      Coming to locking aspect, any method you do the DDL lock is inevitable. so the point is the longer DDL takes the worse the situation in oltp tables. Hence finding the less transactional period for a given table and minimize the impact is only thing I had suggested them.

      -Thanks
      Suresh

  • venkat

    Thank you very much for the post.