SlideShare a Scribd company logo
1 of 24
TUĞBA ŞAHİN
Chapter 5: Redo and Rollback
Chapter 5: Redo and Rollback
Headlines
 Redo
 What Does a COMMIT Do?
 What Does a ROLLBACK Do?
 How Much Redo Am I Generating?
 Can I Turn Off Redo Log Generation?
 Block Cleanout
 Temporary Tables and Redo/Rollback
 Set Transaction
Redo
Redo log files are extremely crucial to the Oracle database.These are the
transaction logs for the database.
They are used only for recovery purposes; their only purpose in life is tobe
used in the event of an instance or media failure.
If the power goes off on your database machine, causing an instance
failure, Oracle will use the online redo logs in order to restore the system
to exactly the point it was at, immediately prior to the power outage.
If your disk drive fails, Oracle will utilize archived redo logs as well as online redo logs
in order to restore a backup of that drive to the correct point in time.
Oracle maintains two types of redo log files, online and archived. Every Oracle
database has at least two online redo log files. These online redo log files are used in
a circular fashion. Oracle will write to log file 1, and when it gets to the end of that
file, it will switch to log file 2, and begin writing to this one.
Redo, or transaction logs, are one of the major features that make a database a
database.
Media failures, when for instance, the hard disk goes bad. Without them, the
database would not offer any more protection than a file system.
What Does a COMMIT Do?
When we COMMIT, all that is left to happen is the following:
• Generate a SCN (System Change Number) for our transaction.
• LGWR writes all of our remaining buffered redo log entries to disk, and records the
SCN in the online redo log files as well. This step is actually the COMMIT. If this
step occurs, we have committed. Our transaction entry is removed, this shows that
we have committed. Our record in the V$TRANSACTION view will ʹdisappearʹ.
• All locks held by our session are released, and everyone who was enqueued
waiting on locks we held will be released.
• Many of the blocks our transaction modified will be visited and ʹcleaned outʹ in a
fast mode if they are still in the buffer cache.
What Does a ROLLBACK Do?
Now, if we change the COMMIT to ROLLBACK, we can expect a totally
different result.
The time to roll back will definitely be a function of the amount of data
modified.
I changed the DO_COMMIT routine we developed in the What Does a
COMMIT Do? Section to perform a ROLLBACK instead (simply change the
COMMIT on line 23 to ROLLBACK) and the timings are very different.
When we ROLLBACK:
We undo all of the changes made. This is accomplished
by reading the data back from the ROLLBACK (undo)
segment, and in effect, reversing our operation. If we
inserted a row, a ROLLBACK will delete it. If we updated
a row, a rollback will reverse the update. If we deleted a
row, a rollback will re‐insert it again.
All locks held by our session are released, and everyone
who was enqueued waiting on locks we held will be
released.
Time Comparison for Commit and
Rollback Operations
Timecommit < Timerollback
How Much Redo Am I Generating?
As a developer, you will find that it can be relevant to be
able to measure how much redo your operations generate.
The more redo you generate, the longer your operations
will take, and the slower the entire system will be.
We saw concrete proof of this above, where a COMMIT for each row took three times
as long as committing when the transaction was complete
Can I Turn Off Redo Log Generation?
This question is often asked. The simple short answer
is ʹnoʹ, since redo logging is crucial
for the database; it is not overhead, it is not a waste.
You do need it, regardless of whether
you believe you do or not. It is a fact of life, and it is the
way the database works. However,
that said, there are some operations that can be done
without generating redo log in some
cases.
Block Cleanout
Stored on the block header. A side effect of this is that
the next time that block is accessed,
we may have to ʹclean it outʹ, in other words, remove
the transaction information. This
action generates redo and causes the block to
become ʹdirtyʹ if it wasnʹt already.
Temporary Tables ve Redo/Rollback
Temporary tables are a new feature of Oracle 8.1.5.
Temporary tables generate no redo for their blocks.
Therefore, an operation on a temporary table is
not ʹrecoverableʹ. When you modify a block in a
temporary table, no record of this change will be
made in the redo log files. However, temporary
tables do generate rollback, and the rollback is
logged.
I set up a small stored procedure to do some SQL on the table, and report the results:
As you can see:
• The INSERT into the ʹrealʹ table generated a lot of redo. Almost no redo was
generated for the temporary table. This makes sense ‐ there is very little rollback
data generated for INSERTs and only rollback data is logged for temporary tables.
The UPDATE of the real table generated about twice the
amount of redo as the temporary table. Again, this makes
sense. About half of that UPDATE, the ʹbefore imageʹ, had
to be saved. The ʹafter imageʹ (redo) for the temporary
table did not have to be saved.
The DELETEs took about the same amount of redo space.
This makes sense as the rollback for a DELETE is big, but
the redo for the modified blocks is very small.
Hence, a DELETE against a temporary table takes place
very much in the same fashion as a DELETE against a
permanent table.
SET TRANSACTION
 The SET TRANSACTION SQL statement may be used
to ʹpickʹ the rollback segment you would like your
transaction to use. This is generally used in order to
have a really big rollback segment for some large
operation.
THANKS
FOR
LISTENING

More Related Content

What's hot

Windows Security in Operating System
Windows Security in Operating SystemWindows Security in Operating System
Windows Security in Operating SystemMeghaj Mallick
 
Hardware supports for Virtualization
Hardware supports for VirtualizationHardware supports for Virtualization
Hardware supports for VirtualizationYoonje Choi
 
Operating system structures
Operating system structuresOperating system structures
Operating system structuresMohd Arif
 
Chapter 5 Presentation
Chapter 5 PresentationChapter 5 Presentation
Chapter 5 PresentationAmy McMullin
 
Chapter 1 Presentation
Chapter 1 PresentationChapter 1 Presentation
Chapter 1 PresentationAmy McMullin
 
Protection and security
Protection and securityProtection and security
Protection and securitymbadhi
 
IP tables and Filtering
IP tables and FilteringIP tables and Filtering
IP tables and FilteringAisha Talat
 
Structure of operating system
Structure of operating systemStructure of operating system
Structure of operating systemRafi Dar
 
Database administration and security
Database administration and securityDatabase administration and security
Database administration and securityDhani Ahmad
 
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION
OPERATING SYSTEMSDESIGN AND IMPLEMENTATIONOPERATING SYSTEMSDESIGN AND IMPLEMENTATION
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION sathish sak
 
Storage area network
Storage area networkStorage area network
Storage area networkNeha Agarwal
 
2 PHASE COMMIT PROTOCOL
2 PHASE COMMIT PROTOCOL2 PHASE COMMIT PROTOCOL
2 PHASE COMMIT PROTOCOLKABILESH RAMAR
 
Identifying Effective Endpoint Detection and Response Platforms (EDRP)
Identifying Effective Endpoint Detection and Response Platforms (EDRP)Identifying Effective Endpoint Detection and Response Platforms (EDRP)
Identifying Effective Endpoint Detection and Response Platforms (EDRP)Enterprise Management Associates
 

What's hot (20)

Data integrity
Data integrityData integrity
Data integrity
 
Windows Security in Operating System
Windows Security in Operating SystemWindows Security in Operating System
Windows Security in Operating System
 
Hardware supports for Virtualization
Hardware supports for VirtualizationHardware supports for Virtualization
Hardware supports for Virtualization
 
Operating system structures
Operating system structuresOperating system structures
Operating system structures
 
Evolution of os
Evolution of osEvolution of os
Evolution of os
 
Chapter 5 Presentation
Chapter 5 PresentationChapter 5 Presentation
Chapter 5 Presentation
 
Chapter 1 Presentation
Chapter 1 PresentationChapter 1 Presentation
Chapter 1 Presentation
 
Protection and security
Protection and securityProtection and security
Protection and security
 
IP tables and Filtering
IP tables and FilteringIP tables and Filtering
IP tables and Filtering
 
Windows server
Windows serverWindows server
Windows server
 
Structure of operating system
Structure of operating systemStructure of operating system
Structure of operating system
 
Distributed Transaction
Distributed TransactionDistributed Transaction
Distributed Transaction
 
Database administration and security
Database administration and securityDatabase administration and security
Database administration and security
 
DB security
 DB security DB security
DB security
 
Database security
Database securityDatabase security
Database security
 
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION
OPERATING SYSTEMSDESIGN AND IMPLEMENTATIONOPERATING SYSTEMSDESIGN AND IMPLEMENTATION
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION
 
Storage area network
Storage area networkStorage area network
Storage area network
 
2 PHASE COMMIT PROTOCOL
2 PHASE COMMIT PROTOCOL2 PHASE COMMIT PROTOCOL
2 PHASE COMMIT PROTOCOL
 
Cache memory
Cache memoryCache memory
Cache memory
 
Identifying Effective Endpoint Detection and Response Platforms (EDRP)
Identifying Effective Endpoint Detection and Response Platforms (EDRP)Identifying Effective Endpoint Detection and Response Platforms (EDRP)
Identifying Effective Endpoint Detection and Response Platforms (EDRP)
 

Similar to Redo and Rollback Chapter

Help! my sql server log file is too big!!! tech republic
Help! my sql server log file is too big!!!   tech republicHelp! my sql server log file is too big!!!   tech republic
Help! my sql server log file is too big!!! tech republicKaing Menglieng
 
You Oracle Technical Interview
You Oracle Technical InterviewYou Oracle Technical Interview
You Oracle Technical InterviewHossam El-Faxe
 
On The Building Of A PostgreSQL Cluster
On The Building Of A PostgreSQL ClusterOn The Building Of A PostgreSQL Cluster
On The Building Of A PostgreSQL ClusterSrihari Sriraman
 
Backing Up and Recovery
Backing Up and RecoveryBacking Up and Recovery
Backing Up and RecoveryMaham Huda
 
What is Database Backup? The 3 Important Recovery Techniques from transaction...
What is Database Backup? The 3 Important Recovery Techniques from transaction...What is Database Backup? The 3 Important Recovery Techniques from transaction...
What is Database Backup? The 3 Important Recovery Techniques from transaction...Raj vardhan
 
Microsoft SQL Server Log Management
Microsoft SQL Server Log ManagementMicrosoft SQL Server Log Management
Microsoft SQL Server Log ManagementStephan Lawson
 
my final ppresenntation.pptx
my final ppresenntation.pptxmy final ppresenntation.pptx
my final ppresenntation.pptxAlifAlAshik2
 
Database architectureby howard
Database architectureby howardDatabase architectureby howard
Database architectureby howardoracle documents
 
Wait events
Wait eventsWait events
Wait eventsAnu Rana
 
Double the Performance of Oracle SOA Suite 11g? Absolutely! (whitepaper)
Double the Performance of Oracle SOA Suite 11g? Absolutely! (whitepaper)Double the Performance of Oracle SOA Suite 11g? Absolutely! (whitepaper)
Double the Performance of Oracle SOA Suite 11g? Absolutely! (whitepaper)Revelation Technologies
 
Backup and recovery in sql server database
Backup and recovery in sql server databaseBackup and recovery in sql server database
Backup and recovery in sql server databaseAnshu Maurya
 
Oracle Database 23c–Fine Grained locking features
Oracle Database 23c–Fine Grained locking featuresOracle Database 23c–Fine Grained locking features
Oracle Database 23c–Fine Grained locking featuresAlireza Kamrani
 
10 Problems with your RMAN backup script - whitepaper
10 Problems with your RMAN backup script - whitepaper10 Problems with your RMAN backup script - whitepaper
10 Problems with your RMAN backup script - whitepaperYury Velikanov
 

Similar to Redo and Rollback Chapter (20)

Help! my sql server log file is too big!!! tech republic
Help! my sql server log file is too big!!!   tech republicHelp! my sql server log file is too big!!!   tech republic
Help! my sql server log file is too big!!! tech republic
 
Redosize
RedosizeRedosize
Redosize
 
You Oracle Technical Interview
You Oracle Technical InterviewYou Oracle Technical Interview
You Oracle Technical Interview
 
Missing redo logs in oracle
Missing redo logs in oracleMissing redo logs in oracle
Missing redo logs in oracle
 
On The Building Of A PostgreSQL Cluster
On The Building Of A PostgreSQL ClusterOn The Building Of A PostgreSQL Cluster
On The Building Of A PostgreSQL Cluster
 
Completerecovery
CompleterecoveryCompleterecovery
Completerecovery
 
Backing Up and Recovery
Backing Up and RecoveryBacking Up and Recovery
Backing Up and Recovery
 
What is Database Backup? The 3 Important Recovery Techniques from transaction...
What is Database Backup? The 3 Important Recovery Techniques from transaction...What is Database Backup? The 3 Important Recovery Techniques from transaction...
What is Database Backup? The 3 Important Recovery Techniques from transaction...
 
8 i ha_enhance
8 i ha_enhance8 i ha_enhance
8 i ha_enhance
 
Oracle NOLOGGING
Oracle NOLOGGINGOracle NOLOGGING
Oracle NOLOGGING
 
Dbms
DbmsDbms
Dbms
 
Microsoft SQL Server Log Management
Microsoft SQL Server Log ManagementMicrosoft SQL Server Log Management
Microsoft SQL Server Log Management
 
my final ppresenntation.pptx
my final ppresenntation.pptxmy final ppresenntation.pptx
my final ppresenntation.pptx
 
Database architectureby howard
Database architectureby howardDatabase architectureby howard
Database architectureby howard
 
Wait events
Wait eventsWait events
Wait events
 
Corruptbkp
CorruptbkpCorruptbkp
Corruptbkp
 
Double the Performance of Oracle SOA Suite 11g? Absolutely! (whitepaper)
Double the Performance of Oracle SOA Suite 11g? Absolutely! (whitepaper)Double the Performance of Oracle SOA Suite 11g? Absolutely! (whitepaper)
Double the Performance of Oracle SOA Suite 11g? Absolutely! (whitepaper)
 
Backup and recovery in sql server database
Backup and recovery in sql server databaseBackup and recovery in sql server database
Backup and recovery in sql server database
 
Oracle Database 23c–Fine Grained locking features
Oracle Database 23c–Fine Grained locking featuresOracle Database 23c–Fine Grained locking features
Oracle Database 23c–Fine Grained locking features
 
10 Problems with your RMAN backup script - whitepaper
10 Problems with your RMAN backup script - whitepaper10 Problems with your RMAN backup script - whitepaper
10 Problems with your RMAN backup script - whitepaper
 

Recently uploaded

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 

Recently uploaded (20)

9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 

Redo and Rollback Chapter

  • 1. TUĞBA ŞAHİN Chapter 5: Redo and Rollback
  • 2. Chapter 5: Redo and Rollback
  • 3. Headlines  Redo  What Does a COMMIT Do?  What Does a ROLLBACK Do?  How Much Redo Am I Generating?  Can I Turn Off Redo Log Generation?  Block Cleanout  Temporary Tables and Redo/Rollback  Set Transaction
  • 4. Redo Redo log files are extremely crucial to the Oracle database.These are the transaction logs for the database. They are used only for recovery purposes; their only purpose in life is tobe used in the event of an instance or media failure. If the power goes off on your database machine, causing an instance failure, Oracle will use the online redo logs in order to restore the system to exactly the point it was at, immediately prior to the power outage.
  • 5. If your disk drive fails, Oracle will utilize archived redo logs as well as online redo logs in order to restore a backup of that drive to the correct point in time. Oracle maintains two types of redo log files, online and archived. Every Oracle database has at least two online redo log files. These online redo log files are used in a circular fashion. Oracle will write to log file 1, and when it gets to the end of that file, it will switch to log file 2, and begin writing to this one. Redo, or transaction logs, are one of the major features that make a database a database. Media failures, when for instance, the hard disk goes bad. Without them, the database would not offer any more protection than a file system.
  • 6.
  • 7. What Does a COMMIT Do? When we COMMIT, all that is left to happen is the following: • Generate a SCN (System Change Number) for our transaction. • LGWR writes all of our remaining buffered redo log entries to disk, and records the SCN in the online redo log files as well. This step is actually the COMMIT. If this step occurs, we have committed. Our transaction entry is removed, this shows that we have committed. Our record in the V$TRANSACTION view will ʹdisappearʹ. • All locks held by our session are released, and everyone who was enqueued waiting on locks we held will be released. • Many of the blocks our transaction modified will be visited and ʹcleaned outʹ in a fast mode if they are still in the buffer cache.
  • 8.
  • 9. What Does a ROLLBACK Do? Now, if we change the COMMIT to ROLLBACK, we can expect a totally different result. The time to roll back will definitely be a function of the amount of data modified. I changed the DO_COMMIT routine we developed in the What Does a COMMIT Do? Section to perform a ROLLBACK instead (simply change the COMMIT on line 23 to ROLLBACK) and the timings are very different.
  • 10. When we ROLLBACK: We undo all of the changes made. This is accomplished by reading the data back from the ROLLBACK (undo) segment, and in effect, reversing our operation. If we inserted a row, a ROLLBACK will delete it. If we updated a row, a rollback will reverse the update. If we deleted a row, a rollback will re‐insert it again. All locks held by our session are released, and everyone who was enqueued waiting on locks we held will be released.
  • 11. Time Comparison for Commit and Rollback Operations
  • 13. How Much Redo Am I Generating? As a developer, you will find that it can be relevant to be able to measure how much redo your operations generate. The more redo you generate, the longer your operations will take, and the slower the entire system will be.
  • 14. We saw concrete proof of this above, where a COMMIT for each row took three times as long as committing when the transaction was complete
  • 15. Can I Turn Off Redo Log Generation? This question is often asked. The simple short answer is ʹnoʹ, since redo logging is crucial for the database; it is not overhead, it is not a waste. You do need it, regardless of whether you believe you do or not. It is a fact of life, and it is the way the database works. However, that said, there are some operations that can be done without generating redo log in some cases.
  • 16. Block Cleanout Stored on the block header. A side effect of this is that the next time that block is accessed, we may have to ʹclean it outʹ, in other words, remove the transaction information. This action generates redo and causes the block to become ʹdirtyʹ if it wasnʹt already.
  • 17.
  • 18.
  • 19. Temporary Tables ve Redo/Rollback Temporary tables are a new feature of Oracle 8.1.5. Temporary tables generate no redo for their blocks. Therefore, an operation on a temporary table is not ʹrecoverableʹ. When you modify a block in a temporary table, no record of this change will be made in the redo log files. However, temporary tables do generate rollback, and the rollback is logged.
  • 20. I set up a small stored procedure to do some SQL on the table, and report the results:
  • 21. As you can see: • The INSERT into the ʹrealʹ table generated a lot of redo. Almost no redo was generated for the temporary table. This makes sense ‐ there is very little rollback data generated for INSERTs and only rollback data is logged for temporary tables.
  • 22. The UPDATE of the real table generated about twice the amount of redo as the temporary table. Again, this makes sense. About half of that UPDATE, the ʹbefore imageʹ, had to be saved. The ʹafter imageʹ (redo) for the temporary table did not have to be saved. The DELETEs took about the same amount of redo space. This makes sense as the rollback for a DELETE is big, but the redo for the modified blocks is very small. Hence, a DELETE against a temporary table takes place very much in the same fashion as a DELETE against a permanent table.
  • 23. SET TRANSACTION  The SET TRANSACTION SQL statement may be used to ʹpickʹ the rollback segment you would like your transaction to use. This is generally used in order to have a really big rollback segment for some large operation.