Realtime views follow-up
I think I already know the answer to this. I have checked previous threads, but as they may be outdated, I just wanted to confirm whether it's still not possible to use realtime with views?
TIA
4 Replies
It is not.
The recommendation in general now is to not use postgres_changes but broadcast from the database on a private channel. You use a trigger to send the data so could put together whatever data you wanted (limit columns, add columns from other tables) in the message sent.
Huh, I did not know that. Is that this ?
If so that might be perfect for my use case once I get to grips with it
Broadcast | Supabase Docs
Send low-latency messages using the client libs, REST, or your Database.
My impression is practically there's not much of a difference with postgres changes, except broadcast would need a trigger. I may be glazing over a couple of details
Yes, but there is another sending function to use at a lower level than the one shown there that lets you format you data exactly as you want.
So basically your trigger function can put only columns you want and gather other data and send in a format you want.
The other reason to use broadcast is it is much much less resource load than postgres changes with RLS. It does RLS on channel subscribe and not every change.