November 2019
Beginner to intermediate
470 pages
11h 59m
English
In my life as a professional PostgreSQL consultant (https://www.cybertec-postgresql.com), I have seen a couple of mistakes that are repeated frequently. If there are constants in life, these typical mistakes are definitely some of the things that never change.
Here is my favorite:
|
Transaction 1 |
Transaction 2 |
|
BEGIN; |
BEGIN; |
|
SELECT max(id) FROM product; |
SELECT max(id) FROM product; |
|
User will see 17 |
User will see 17 |
|
User will decide to use 18 |
User will decide to use 18 |
|
INSERT INTO product ... VALUES (18, ...) |
INSERT INTO product ... VALUES (18, ...) |
|
COMMIT; |
COMMIT; |
In this case, there will be either a duplicate key violation or two identical entries. ...