Skip to content

Comment on Using Postgres Arrays in Djangoparent

Comments

Arrays in postgres are incredibly useful for some things. For instance if you use gist or gin index (I forget which), you can do fast intersection queries on arrays.

This is really useful if you want to do something like get all the posts with a certain set of tags: `select posts.tags && ARRAY['postgres', 'arrays']`.

It's also useful for implementing things like materialized paths if you're modeling hierarchies, or adjacency lists if you're modeling graphs I suppose.

Of course all of this could be done with small join tables, but the array intersection / set syntax gives you some nice tools.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.