HNHacker News
TopNewBestAskShowJobs

uhoh-itsmaciek

516 karma · joined April 27, 2016

submissionscomments
uhoh-itsmaciek··on Folk Interfaces
Folk interfaces are a natural consequence of the focus on building applications for millions of users and the dearth of situated software [1]. They're also a clever way of claiming no-code or low-code platforms in unexpected places.

[1]: https://www.gwern.net/docs/technology/2004-03-30-shirky-situ...

uhoh-itsmaciek··on Folk Interfaces
Could you talk about some concrete examples?
uhoh-itsmaciek··on Singing: The key to a long life (2008)
I started playing bluegrass mandolin some years ago. I never really thought I could sing, but after starting to get into the local jam scene, I saw what a big part singing played and wanted to give it a shot. I took some classes and some workshops, and eventually started to get comfortable with both lead and harmony singing (I'm not good by any means, but competent enough for the jam scene).

If you listen to some of the classic bluegrass recordings, there's an incredible amount of nuance and control in the vocals, and trying to sing along and learn those subtleties is challenging and rewarding. And because there's a strong tradition of harmony in this music, the sustained vowel sounds Eno talks about are everywhere.

While the group singing Eno talks about is generally frowned upon in bluegrass, nailing a close harmony stack with one to three other people (depending on the parts) is a fantastic feeling. Building relationships around that, where you're looking forward to the next festival or music camp because you'll get to sing with someone again, is even better.

I got into this music for playing my instrument with others, but while I still enjoy that, I appreciate the singing a lot more now.

uhoh-itsmaciek··on Elizabeth Cotton’s Fingerstyle Ragtime
Not just normal lefty: she's playing a regular "right handed" guitar, flipped around. Note how the thin strings are on top and the heavy strings on the bottom.
uhoh-itsmaciek··on Shipping Multi-Tenant SaaS Using Postgres Row-Level Security
>Another issue we caught during testing was that some requests were being authorized with a previous request’s user id.

This is the terrifying part about RLS to me: having to rely on managing the user id as part of the database connection session seems like an easy way to shoot yourself in the foot (especially when combined with connection pooling). Adding WHERE clauses everywhere isn't great, but at least it's explicit.

That said, I've never used RLS, and I am pretty curious: it does seem like a great solution other than that one gotcha.

uhoh-itsmaciek··on Shipping Multi-Tenant SaaS Using Postgres Row-Level Security
There are some other cons:

Memory usage and I/O can be less efficient. Postgres handles table data in 8kb pages, so even if you're just reading a single row, that reads 8kb from disk and puts 8kb in the Postgres buffer cache, with that row and whatever happens to be next to it in the physical layout of the underlying table. Postgres does this because of locality of reference: it's cheaper to bulk-load data from disk, and, statistically speaking, you may need the adjacent data soon. If each user is touching separate tables, you're loading a page per row for each user, and you're missing out on some of the locality benefits.

Another problem is monitoring (disclosure: I work for pganalyze, which offers a Postgres monitoring service). The pg_stat_statements extension can track execution stats of all normalized queries in your database, and that's a very useful tool to find and address performance problems. But whereas queries like "SELECT * FROM posts WHERE user_id = 123" and "SELECT * FROM posts WHERE user_id = 345" normalize to the same thing, schema-qualified queries like "SELECT * FROM user_123.posts" and "SELECT * FROM user_345.posts" normalize to different things, so you cannot easily consider their performance in aggregate (not to mention bloating pg_stat_statements by tracking so many distinct query stats). This is the case even when you're using search_path so that your schema is not explicitly in your query text.

Also, performance of tools like pg_dump is not great with a ton of database objects (tables and schemas) and, e.g., you can run into max_locks_per_transaction [1] limits, and changing that requires a server restart.

I wouldn't say you should never do schema-based multi-tenancy (you point out some good advantages above), but I'd be extremely skeptical of using it in situations where you expect to have a lot of users.

[1]: https://www.postgresql.org/docs/current/runtime-config-locks...

uhoh-itsmaciek··on Column order in PostgreSQL does matter
For what it's worth, there is currently some active work in this area [1]. It's too late for 15, but it might land in 16 (next fall).

[1]: https://www.postgresql.org/message-id/flat/20220628083230.c4...

uhoh-itsmaciek··on The popularity of country music in rural sub Saharan Africa
American country music has been heavily influenced by African Americans since the beginning (often without recognition, though that's starting to change.) The banjo is based on African instruments, and many musicians like Huddie Ledbetter, Elizabeth Cotten, Mississippi John Hurt, Arnold Shultz, and DeFord Bailey helped shape the genre. It's great to see this popularity in Africa--in a weird way, it's almost like coming full circle.
uhoh-itsmaciek··on Sci-Fi Films Everyone Should Watch Once
Any list like this will have omissions, but yeah, Gattaca is great. Primer should be there, too.
uhoh-itsmaciek··on Speeding up sort performance in Postgres 15
>Variable length strings are kept in a separate file (TOAST tables), referenced by the tuple. This keeps records fixed size...

That's not entirely true: variable-width row values under a size threshold are stored inline (possibly compressed).

The beauty part about TOAST is that they're mostly just regular tables (any table that needs its data TOASTed gets its own TOAST table). You can look them up in the system catalogs and query them directly.

The schema for these is (chunk_id, chunk_seq, chunk_data). Chunk "pieces" are limited in size so they can be stored inline (obviously there's not much benefit to a TOAST table itself having a TOAST table), so any row values that need to be TOASTed may also be broken up into multiple pieces. Row values stored inline in the "owning" table reference a chunk_id where the TOASTed data is stored, and queries that need to return that data look up all the chunks for a chunk id, ordered by chunk_seq.

You're right that this scheme avoids reading TOASTed data when you're not actually using it (a good reason to avoid "SELECT *" if you've got big TOASTed data).

uhoh-itsmaciek··on Speeding up sort performance in Postgres 15
There's a pretty good high-level overview of the implementation details in the official docs: https://www.postgresql.org/docs/current/storage.html
uhoh-itsmaciek··on Ask HN: What are your favorite examples of elegant software?
Sequel [1], the Ruby ORM. It's rock-solid, provides similar abstractions to Active Record but feels much better thought out, and it has great docs.

Also, at any point in time, it's likely to have zero open issues and zero open pull requests, which is pretty impressive for a project of its size.

[1]: https://github.com/jeremyevans/sequel

uhoh-itsmaciek··on How Postgres chooses which index to use for a query
I don't see anything in the 2022 blog post that contradicts the 2014 mailing list post. These are different features with different trade-offs and somewhat overlapping use cases.
uhoh-itsmaciek··on How Postgres chooses which index to use for a query
They're not really the same thing: https://www.postgresql.org/message-id/CAM3SWZRP0c3g6+aJ=YYDG...
uhoh-itsmaciek··on What chords do you need?
No problem. In country and bluegrass jamming circles, there's definitely a faction that prefers simpler songs with fewer chords (true to Howard's quote), so I was amused to see his words distorted. Thanks for fixing it.
uhoh-itsmaciek··on What chords do you need?
Three chords and the truth. Usually attributed to Harlan Howard [1], an early country music songwriter. A lot of early country music sticks to just I, IV, and V.

[1]: (PDF) https://countrymusichalloffame.org/content/uploads/2019/05/W...

uhoh-itsmaciek··on Migrating from SQLite to PostgreSQL
As some other replies noted, Postgres does not support that. Some drivers or ORMs do their own pre-processing on query text, and add their own support for that. E.g., in ActiveRecord, you can do:

    User.where("status = ?", "active").all
ActiveRecord itself sanitizes the input here and the query that's sent to Postgres does not use parameter markers at all.
uhoh-itsmaciek··on Advice on JSX Conditionals
Yeah, this is generally a good compromise. I sometimes like to write these as helper components instead:

  <Layout>
    <Header />
    <Content page={page} />
    <Footer />
  </Layout>

  const Content = ({page}) => {
    switch (page) {
      case 'home': return <Home />
      case 'about': return <About />
      default: return <NotFound />
    }
  }
uhoh-itsmaciek··on How does database indexing work? (2008)
Right, Postgres supports this use case explicitly with INCLUDE [1], which can be more efficient than just indexing all the columns you need. Pretty sure SQL Server has something similar.

[1]: https://www.postgresql.org/docs/current/sql-createindex.html

uhoh-itsmaciek··on SPAs Were a Mistake
I don't know. I'm not very familiar with Next.js (I'd heard about it but never really looked into it much). Your response inspired me to investigate, and I found an article by a Remix founder about the differences [1]. It's obviously biased, but maybe still interesting. It looks like there was an HN submission and a bit of discussion, too.

There's a bunch of other comparisons out there, too.

[1]: https://remix.run/blog/remix-vs-next [2]: https://news.ycombinator.com/item?id=29983950

uhoh-itsmaciek··on SPAs Were a Mistake
I think it's exciting to see frameworks like https://remix.run/ trying to temper the disadvantages of SPAs by relying on web standards and server-side rendering. It's pretty cool that this is a JavaScript framework that can work without any (client-side) JavaScript.
uhoh-itsmaciek··on PostgreSQL Schema Change Guide
Note that SQL-standard bodies are supported as of 14 [1]:

    Allow SQL-language functions and procedures to use SQL-standard function bodies (Peter Eisentraut)

    Previously only string-literal function bodies were supported. When writing a function or procedure in SQL-standard syntax, the body is parsed immediately and stored as a parse tree. This allows better tracking of function dependencies, and can have security benefits.
[1]: https://www.postgresql.org/docs/14/release-14.html
uhoh-itsmaciek··on How PostgreSQL stores rows
This post glosses over it, but larger fields are stored via the TOAST mechanism [1], which does support compression.

[1]: https://www.postgresql.org/docs/current/storage-toast.html

uhoh-itsmaciek··on Fretastic: Guitar fretboard visualizer – scales, intervals, backing tracks
Check out https://fretboard.cool and tell me what tunings to add! Or submit a PR [1].

[1]: https://github.com/uhoh-itsmaciek/fretboard.cool/blob/master... (there's a quirk noted in the TODO there so you need to shift the fifth string down a fourth when specifying the tuning).

uhoh-itsmaciek··on Fretastic: Guitar fretboard visualizer – scales, intervals, backing tracks
Neat! If anyone wants to check out a very, very basic version of a similar idea, I built https://fretboard.cool a couple of years ago.
uhoh-itsmaciek··on Who Contributed to PostgreSQL Development in 2020 and 2021?
If anyone wants to keep up with Tom Lane's prolific mailing list contributions without subscribing to the pgsql-hackers firehose, I wrote a Twitter bot that tweets the last sentence (according to some mostly-working regex heuristics) from his e-mails: https://twitter.com/regardstomlane

Postgres is a fantastic community.

uhoh-itsmaciek··on Tips for a Healthier Postgres Database
Due to some Postgres limitations, a query can run even after the connection drops (the backend process only checks if there's still a client to send results to after query completion). I think I saw some work being done on this in 14 or the upcoming 15 (i.e., to re-check periodically during query processing), but a lot of Postgres versions are still affected. I worked on the Heroku Data team and we regularly saw queries running for days. I think starting with an aggressive timeout to fail fast where you can't afford a slow query anyway, and then make exceptions where it makes sense, is easier to work with than tracking down problem cases and putting in limits after they cause issues.
uhoh-itsmaciek··on Tips for a Healthier Postgres Database
I think there's a case to be made that a timeout is more important. With an OLTP workload, it's not hard to imagine a runaway query running for days, consuming I/O bandwidth and silently slowing everything down. A timeout may break some things, but it will do so a lot more clearly. (Of course, both settings are a good idea.)
uhoh-itsmaciek··on Tips for a Healthier Postgres Database
It should, but it may need to be tuned to run aggressively enough, which can be tricky. Sometimes it's easier to just schedule a manual job that runs during your off hours. There are some interesting discussions on the Postgres development list on improving VACUUM performance [1] and other improvements to the overall MVCC mechanism to avoid the need for VACUUM in the first place if possible [2]. Postgres, like any complex system, does have pathological cases. It helps to keep an eye on performance and learn the system as your database grows. But it's good to see the community is thinking about how to improve the situation.

[1]: https://www.postgresql.org/message-id/flat/CA%2BTgmoZgapzekb... [2]: https://www.postgresql.org/message-id/flat/CAH2-Wz%3DsSvMX5H...

uhoh-itsmaciek··on Show HN: HTML/CSS Photo Sheet
Also not working here on FF/Linux. Tried Chrome and it's pretty nice. One odd thing I noticed: if I click on an image and then click left or right to go forward or back, after mouse down but before mouse up, the picture index shows "35/35" (it shows the correct position once I release the mouse button).
← PreviousPage 4 of 7Next →