Created
May 10, 2017 12:24
-
-
Save scaint/932f0a1b497003670e5cd96f507e15da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TEMP TABLE beer(name text); | |
INSERT INTO beer VALUES ('Guinness'); | |
SELECT * FROM beer; | |
-- name | ctid | |
------------+------- | |
-- Guinness | (0,1) | |
-- (1 row) | |
UPDATE beer SET name = 'Guinness' WHERE name != 'Guinness'; | |
-- UPDATE 0 | |
SELECT * FROM beer; | |
-- name | ctid | |
------------+------- | |
-- Guinness | (0,1) | |
-- (1 row) | |
SELECT n_dead_tup FROM pg_stat_user_tables WHERE relname = 'beer'; | |
-- n_dead_tup | |
-------------- | |
-- 0 | |
-- (1 row) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TEMP TABLE beer(name text); | |
INSERT INTO beer VALUES ('Guinness'); | |
SELECT * FROM beer; | |
-- name | ctid | |
------------+------- | |
-- Guinness | (0,1) | |
-- (1 row) | |
UPDATE beer SET name = 'Guinness'; | |
-- UPDATE 1 | |
-- value hasn't been changed, but... | |
SELECT * FROM beer; | |
-- name | ctid | |
------------+------- | |
-- Guinness | (0,2) | |
-- (1 row) | |
-- ...we got a dead tuple and it should be vacuumized in future | |
SELECT n_dead_tup FROM pg_stat_user_tables WHERE relname = 'beer'; | |
-- n_dead_tup | |
-------------- | |
-- 1 | |
-- (1 row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment