HN user

andorov

133 karma
Posts0
Comments41
View on HN
No posts found.
Idempotency 3 years ago

I always remember this from the example my professor gave -

   'raise the control rods by 1 inch' 
vs 'raise the control rods to a height of 4 inches'
Upsert in SQL 3 years ago

worth re-upping -

postgres requests an id from the sequence for each row of the incoming data ahead of time since it doesn't know which rows are updates and which are inserts (although presumably this could be changed?). the sequence doesn't reset down for the unused so this can eat through it unexpectedly quickly if you have a table with a relatively large volume of updates.

also as a tip if you hit the max integer for the sequence and need space to implement a fundamental fix you can quickly change the sequence to start at -1 and go down. there's no issue with negative ids since they're also integers.

Similar quote from Lao Tzu. I like the inclusion of thoughts -> words -> actions.

"Watch your thoughts, they become your words;

watch your words, they become your actions;

watch your actions, they become your habits;

watch your habits, they become your character;

watch your character, it becomes your destiny."

this also matters if you do a lot of upserts on a table that are predominantly updates. postgres requests an id from the sequence for each row of the incoming data ahead of time since it doesn't know which rows are updates and which are inserts. the sequence doesn't reset down for the unused so this can eat through it unexpectedly quickly.

if you hit the max integer for the sequence and need space to implement a fundamental fix you can quickly change the sequence to start at -1 and go down. there's no issue with negative ids since they're also integers.

DRY needs to be balanced with SRP (Single Responsibility Principle). You can legitimately have two functions that are exactly the same but they should not be DRY'd up if they are actually serving different purposes.

The use cases will likely diverge in the future, and if the functions are DRY'd making changes will make introducing bugs from the calling code that you're not working on easy. Eventually the single function will likely have a lot of conditions in it, which is a red flag for this situation.

I'm not presenting an argument against UBI - I am pointing out that his argument is flawed.

Small tribes of humans defending hunting/foraging grounds is a state of pre-civilization. Life required work then too, and things were worse. His premise is that things used to be better and we've made it worse. Hard disagree.

Land used to exist without a monetary cost to access it. That was the natural way of things prior to the private property system and monetary system.

All land / resources were staked out by small tribes of humans who might kill you for using it?

X-COM 6 years ago

Heh also firing a stun grenade into your ship at the end of a mission. Promotions for everyone!

Thank you for your work! Postgres is great to use and the regular release of useful features has been a very nice benefit.

One unobvious (to me) but possibly necessary side effect of the INSERT...ON CONFLICT pattern is that it reserves a primary id for every row ahead of time, presumably because it does not know what will be updated and what will be inserted. We have a heavily updated table that started failing inserts one day because the primary id sequence hit the max int (2.1b), despite the table only reaching 100mm rows. The immediate fix was to reset the sequence to -1 and have it start going down...

I think it is also useful to be aware of the specific terms your team might need and introduce words to those more abstract concepts. This frequently happens with naming specific code patterns or important classes in the code, but can also be for how the team operates in general. A DSL for how your team operates.

In Peru I saw are several very large stones sitting on the trail between the quarry and a partially finished temple. One of them at the bottom of a very steep hill. Our guide did speculate that getting the stones on site was a gradual process.