The custom domains trap: your own datatypes skip the index
We love PostgreSQL domains. Our schema has more of our own datatypes than plain ones
Then we found that every one of them quietly skips its index when compared to current_user
TL;DR
-- index skipped: your domain is cast down to text
where t.client = (select get_client(current_user))
-- index used
where t.client = (select get_client(current_user::text collate "default"))