Re:What PostgreSQL has over other open source SQL databases:...
by b3n on Sunday October 25, 2015 @07:19PM
(#10448862)
I don't know much about SQL, but are you sure you need multiple joins for that?
I'd do something like this (psuedocode) on the table with the tags:
SELECT foreign-id, COUNT(*)
FROM Tags
WHERE tag IN ('foo', 'bar', 'baz')
GROUP BY foreign-id
HAVING COUNT(*) = 3
It does seem rather hacky though.
Re:What PostgreSQL has over other open source SQL databases:...
by Veratyr on Monday October 26, 2015 @12:00AM
(#10449539)
Hmm, I don't know much about it either and it looks like you're right. I don't believe that querying it is nearly as fast as querying a GIN index (or as easy) still.
With Postgres I just do this and it gives me a result in a couple ms:
SELECT * FROM things WHERE ARRAY['tag1', 'tag2'] <@ tags;
But with Postgres, you can put a GIN index on an Array column. So I moved my tags into an array column and suddenly querying for every one of several million rows that had matched a set of 7 tags took ~10ms.
Postgres is awesome.