Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Troubleshooting PostgreSQL

You're reading from  Troubleshooting PostgreSQL

Product type Book
Published in Mar 2015
Publisher Packt
ISBN-13 9781783555314
Pages 164 pages
Edition 1st Edition
Languages

Table of Contents (17) Chapters

Troubleshooting PostgreSQL
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Installing PostgreSQL Creating Data Structures Handling Indexes Reading Data Efficiently and Correctly Getting Transactions and Locking Right Writing Proper Procedures PostgreSQL Monitoring Fixing Backups and Replication Handling Hardware and Software Disasters A Standard Approach to Troubleshooting Index

The PostgreSQL transaction model


The PostgreSQL transaction model differs quite a lot from other systems. In many cases, these differences are a root source of trouble. In this section, some basic examples have been included to make you aware of the way PostgreSQL works.

The first thing to take into account is that a transaction block has to be started with BEGIN statement and finished with a simple COMMIT statement All statements inside the transaction block have to be correct:

test=# BEGIN;
BEGIN
test=# SELECT now();
              now              
-------------------------------
 2014-09-22 13:27:24.952578+02
(1 row)

test=# SELECT now();
              now              
-------------------------------
 2014-09-22 13:27:24.952578+02
(1 row)

test=# COMMIT;
COMMIT

Note that now() will return the transaction time. Therefore it is always the same, regardless of how often it is used. Many people like to use DEFAULT now() in their column definitions. Always keep in mind that DEFAULT now() sets...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}