Live data from Hacker News

Careful with That Lock, Eugene

kaveland.no

11–18 of 18 posts

Re: Careful with That Lock, Eugene

#11
It doesn't make the article less interesting but this statement is wrong most of the time

> This scenario is essentially identical to one in which there's a single migration statement that requires an `AccessExclusiveLock` and performs a table rewrite, such as adding a NOT NULL column with a DEFAULT value.

Unless the `DEFAULT` value is `VOLATILE` (this is rarely the case as usually default values are at least `STABLE`) no table rewrite is necessary since Postgres 11.

https://www.postgresql.org/docs/devel/sql-altertable.html

> Many other useful performance improvements, including the ability to avoid a table rewrite for ALTER TABLE ... ADD COLUMN with a non-null column default

https://www.postgresql.org/docs/release/11.0/

Re: Careful with That Lock, Eugene

#13
post #7
post #5

In the Rails world, the gem strong_migrations can be used to detect these: https://github.com/ankane/strong_migrations The docs include a handy articulation of fixes.

ankane is some kind of superhuman cyborg. Seems like about 25% of the really useful gems I use have that name in the URL...

Pghero is kind of gem

Re: Careful with That Lock, Eugene

#14
post #3

For you young whippersnappers (are there any old whippersnappers?), the title refers to a Pink Floyd song called "Careful With That Axe, Eugene".

That primal scream fitted perfectly into the final scene of Zabriskie Point... https://youtu.be/dcSMv44jgls?t=4m08s

Stunning. You have to imagine it was right there in the script.

Re: Careful with That Lock, Eugene

#15

It doesn't make the article less interesting but this statement is wrong most of the time > This scenario is essentially identical to one in which there's a single migration statement that requires an `AccessExclusiveLock` and performs a table rewrite, such as adding a NOT NULL column with a DEFAULT value. Unless the `DEFAULT` value is `VOLATILE` (this is rarely the case as usually default values are at least `STABLE…

Thanks, I will fix this part. As far as I can tell, it is only the example of what can cause the table rewrite that's wrong, so it would be correct if the example was to make a varchar shorter? Although I guess that's not a table rewrite, only a long validation...

Re: Careful with That Lock, Eugene

#16
post #5

In the Rails world, the gem strong_migrations can be used to detect these: https://github.com/ankane/strong_migrations The docs include a handy articulation of fixes.

This is super cool, I love how it suggests safer ways to achieve the same goal for many common risky migrations. Definitely going to sit down and study these.
Post reply on HN