I'm not sure if PostgreSQL would correctly optimize the correlated subquery, so this switches back to a pure join approach. This puts all conditions in the JOINs, avoiding the use of WHERE. When we move to supporting personal access tokens, this should be trivial to expand to multiple subjects (both account and personal access token subjects) in a single query, using a loop for the subject joins over all provided subjects. This is similar in nature to the original SQL query, before it was switched to a correlated subquery, but the joins are in a different order.
5.9 KiB
5.9 KiB