7,244 karma · joined Sep 25, 2010 (16y ago) · 2,593 submissions
comment 6y ago · link · parent
Global supply chains are a fact of life. The strongest fighter against over-dependence on China is Trump, and he was ridiculed as "protectionist". Trump's travel restrictions were similarly ridiculed.
Strategic stockpiles are spotty. Sometimes the thing you stockpile is what you need; often not. Did every other country have a stockpile of masks except the US?
comment 6y ago · link · parent
There's a tendancy to compare the results of a system to what a wise, common-sense person with 20/20 hindsight would do if they were in charge. But that's not how things work. People in a system often fall victim to all kinds of bad assumptions, often thinking that others are wholly or partially responsible for dealing with a particular risk.
It looks like the US was caught flat-footed. It's too early to say how resilient we are, though. And it's way too early to start trying to push specific political angles like the idea that some mythical-but-non-specific non-capitalist system would have served us better.
comment 6y ago · link · parent
And let's have some humility here. No matter what such a retrospective shows, it's pretty hard to learn any real lessons from this kind of thing. We will almost certainly just overfit our institutions to fight the next coronavirus; I doubt we will better at handling crises in general.
It's still possible that the US will have a reasonable outcome. Let's do what we can to make that happen and make use of our advantages. More cars and less public transport may make physical distancing more effective.
comment 6y ago · link · parent
The 2008 crunch was almost purely financial. Let's get past this pandemic and then see where the businesses shake out financially.
comment 6y ago · link · parent
The problem is buffering. Normally, buffering happens within the supply chain -- the back rooms of stores, loaded in trucks, warehouses, distribution centers, and the factories themselves. Now, we are telling everyone "buffer at home so you don't need to go out so much". But the problem is, buffering is much less efficient at the end of the chain, so you need to buffer a lot more. That's causing a short-term strain on production and distribution.
Blaming selfishness or gouging probably doesn't do much to help this problem. My guess is that the biggest problem is the discrepancy between how much stuff would be needed to buffer within the supply chain versus how much stuff is needed to buffer at the end of the supply chain (i.e. at home).
Worse, because it's a temporary buffering problem and there's no real increase in consumption, there's little incentive for production to increase now to alleviate it. Any increased production/distribution now just means less demand later when people start to work through their caches at home (and stop buying for a while).
So the only way to alleviate this is to allow the prices (that manufacturers charge) to rise, which will give manufacturers a cushion against the inevitable slump in the future. That's not very popular and not worth the brand damage, so it won't happen.
The good news is that I don't think this will last more than another few weeks. Gougers will stop buying at some point because they don't want to get stuck with a huge supply of toilet paper and no channels to sell it. And the home caches will fill up.
EDIT: this analysis has nothing to do with things like facemasks, where consumption has dramatically risen.
comment 6y ago · link · parent
Additionally, streams are not generally safe to drink from, despite how pristine they may look[1].
[1] https://www.cdc.gov/healthywater/drinking/travel/index.html
comment 6y ago · link · parent
comment 6y ago · link · parent
Maybe there's some kind of slippery slope there, where they eventually start sending you to church for a parking ticket. But we don't seem to be sliding to that conclusion very quickly; so if it works, just go with it.
If you want to make a big federal case out of it, you could probably win it. But I honestly don't see how anyone wins with that outcome.
comment 6y ago · link · parent
EDIT: maybe not. This one had a warrant rather than a subpoena. I'd still be interested in the interaction though.
comment 6y ago · link · parent
In practice it doesn't always hold up very well.
Do you have an alternative suggestion? Would the government always pay for the entire defense? Or reimburse if the accused is acquitted?
This is also why gun violence restraining orders are bad. Large costs to the defendent with no standards or hearing or even an accusation of a crime.
comment 6y ago · link · parent
So if you don't start out with any NULLs, and you have complete and unambiguous knowledge of your entire data set, how does "unknown" get injected into such an innocent-looking example?
comment 6y ago · link · parent
Configuration settings that change SQL semantics are just too dangerous.
From the official docs:
"Note that this option only affects the exact form = NULL, not other comparison operators or other expressions that are computationally equivalent to some expression involving the equals operator (such as IN). Thus, this option is not a general fix for bad programming."
https://www.postgresql.org/docs/12/runtime-config-compatible...
I know it seems tempting to use this setting as a convenience, but I strongly recommend against it.
comment 6y ago · link · parent
But yes, I think left join is fundamentally about grouping, and grouping would be better solved with set-valued attributes or relation-valued attributes.
I wouldn't call that "hierarchically-structured data" because that has the connotation that the data is actually stored in a hierarchy, which I think is generally a bad idea (though not always).
comment 6y ago · link · parent
A language should help you avoid making mistakes, not trick you into making them. The path of least resistance should be the safest and most normal thing, and SQL fails here.
comment 6y ago · link · parent
But that's just weird -- in a normal programming language you would never duplicate the tuples and make this mess; you would keep a single tuple on the LHS and group the RHS into a set (or array/list). Then you'd aggregate the set on the RHS. That model is simple because an empty set is a value with known semantics (sum of an empty set is zero), whereas a half-NULL row is just a hack.
Before someone asks, this has nothing to do with declarative/imperative, and nothing to do with some purity of the relational model. You can still have a declarative relational model with values that happen to be sets (or even relations).
comment 6y ago · link · parent
-- Find all customers with total orders
-- less than $100 in 2019
SELECT c.name
FROM customers c LEFT JOIN orders o
ON (c.id = o.customer_id)
WHERE DATE_TRUNC('year', o.ts) = '2019-01-01'::timestamptz
GROUP BY c.name
HAVING SUM(o.price) < 100;
Can you find the problem?[ SPOILER ]
The problem is if there is a customer with no orders. The left join will produce NULLs for the attributes of "orders", and SUM() will sum them up to NULL because it thinks NULL means "nothing". The predicate "NULL < 100" will then think the NULL means "unknown" and produce the result "unknown". Then, the HAVING clause treats NULL like FALSE, and does not produce the row.