For readers who want all of these and more in book form, with a sample Rails app and big data to test with (generated), please consider my book:
High Performance PostgreSQL for Rails https://news.ycombinator.com/item?id=38407585
The book helps readers build database skills with the overall purpose of improved performance and scalability.
Again, great, concise article. I’ll be recommending it to others and it will help a lot of developers!
Thanks!
CDNs are another way to track everybody. So privacy is an excellent reason for not using a CDN.
Pretty sure this only applies to HTTP/1 and you'll get better performance with HTTP/2:
"Connection-specific header fields such as Connection and Keep-Alive are prohibited in HTTP/2 and HTTP/3"
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Ke...
"HTTP persistent connection, also called HTTP keep-alive, or HTTP connection reuse, is the idea of using a single TCP connection to send and receive multiple HTTP requests/responses, as opposed to opening a new connection for every single request/response pair. The newer HTTP/2 protocol uses the same idea and takes it further to allow multiple concurrent requests/responses to be multiplexed over a single connection."
Ever read those articles that explain half the internet is unavailable because of some random e.g. cloudflare outage? That.
CREATE INDEX index_accounts_balance ON accounts (id) WHERE boolean_flag;
The purpose of the index often is to lower the “cost” (greater profit), by providing more values the query is accessing (filtering, ordering, selecting) within the index entries, for faster retrieval.
When users have the skills to generate query plans and review whether an index supports a query, verifying that the index is picked by the planner, and indeed lowers the cost, then they can answer this question for their own unique combination of hardware, data distribution, queries, and indexes.
As generic advice, I think more often than not the index won’t be used for Boolean columns. But it’s generic advice and it does depend.
As you suggested, users must check their own system.
My book also covers the 2 and 3 value variations (nulls allowed) for Boolean columns.
For readers wanting to build these skills themselves, here’s more info:
https://news.ycombinator.com/item?id=38407585
Good nudge that it depends!
Also, a proficient developer looks at the SQL logs anyway as they develop a given feature.
Rails' flavor of ORM is particularly composable and transparent - you can easily mix/match it with vanilla SQL.
This is a place where I think tools like Rubocop help. They can be configured to point out method swaps like this (size over count) automatically which is a relatively low effort task to change the code.
With those rules/linting in place, you aren’t throwing out the benefits of AR (ORM), and hopefully leveraging their useful methods like these that help avoid unnecessary queries.
More concretely, performance is on my list of "good problems to have". Businesses die in the time it takes to write raw SQL.
I assume this is telling us it doesn't actually make an ActiveRecord instance out of each row when you do that. And instantiating big bunches of ActiveRecord model instances just to grab a few fields from a result set with a lot of rows can be sooo slow.
the CDN fauxpas is forgiven, nobody is perfect
I can't even read the site with that text contrast. Why is illegibility a trend at all?