News for hackers. Stuff that matters.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by mmcgaha on Saturday February 27, 2021 @09:38AM (#26285114)
Arrays in Postgres are my guilty pleasure. I know I shouldn’t use them but I just cannot help myself.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by lucian1900 on Saturday February 27, 2021 @09:45AM (#26285150)
They’re great for denormalisation, which is often an appropriate trade off.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by bitexploder on Saturday February 27, 2021 @09:52AM (#26285193)
Even storing JSON blobs isn’t the hit it used to be. It’s not relational, but you can index on fields in the JSON and query it effectively. The Postgres array and other types are great for stuff at the edges of your database or when you know you won’t need to build relations into or on that data. RDBMS like Postgres really provide a powerful, powerful technology for managing data.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by colanderman on Saturday February 27, 2021 @10:04AM (#26285255)
Yes! Have one-to-many data that you know you will usually always grab all in one go, and won't ever participate in a relation? Arrays are the way to go. JSONB can be similarly highly appropriate. They can greatly reduce the number of disk reads needed for certain workloads.

Don't forget that both can be indexed in Postgres! And the indexes are more powerful than what you can do with the equivalent relational layout, as they support efficient subset queries.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by sk5t on Saturday February 27, 2021 @01:03PM (#26286700)
Same goes for hstore and the @> style operators.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by EdwardDiego on Saturday February 27, 2021 @11:50PM (#26290779)
I've recently used them to replace a many to many relation from table A to table B where the primary query was "give me all As associated with B", so the new table had a schema of unique B, Array<A>, so what was a 20ish second query over several hundred million rows became a 0.3 second query over 600K rows.

We did have a use case that wanted to find Bs for a given A, and using a GIN index on the array column along with the PG array contains operator served that up remarkably fast also.