Chapter 4. Understanding Transactions

Transactions are an interesting and useful feature of PostgreSQL. All sophisticated database systems offer some kind of transaction code these days.

When modifying data in a transaction-enabled database, the database uses some kind of “everything or nothing” algorithm. Imagine a DELETE statement that has to delete several thousand rows. If someone presses the reset button while the operation is running, you might run into trouble because only half of the table might have been deleted. You also might face integrity problems. To avoid such nasty occurrences, a highly sophisticated transaction-based system has been implemented in PostgreSQL.

Imagine a user starting a DELETE statement that affects millions of rows. ...

Get PostgreSQL Developer's Handbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.