Realtime Postgres Changes vs Broadcast
Hey all, I am currently working on a collaborative Google Docs/Notion clone in NextJS as a personal project. I saw the recent video from supabase talking about the new broadcast feature, and it had me wondering whether or not I should use Postgres Changes or Broadcast to ensure that all users of a project page have the most updated information from the database. Apart from Broadcast being more performant and having the ability to filter and add data to the payload delivered to the clients, are there any other major differences between the two features that I should be aware of? Which realtime feature would you use in this situation?
6 Replies
I assume you mean a few tables and not the entire database.
I'm switching postgres_changes to the broadcast method whenever I get back to working on that part of my own project.
The other thing it allows is to deal with losing the connection and not missing data. When you reconnect you can, based on a timestamp of last update) go and load all the missed messages from the last one you got potentially with the message table, but worst case with your own message history table that gets cleaned with cron after a "safe" amount of time.
Ah yes i mean a couple of tables.
Im not quite sure about what you mean about a messages table. In my project I have two realtime tables that clients will receive payloads from. Would those be my “messages” tables in that case?
There is a realtime.messages table that the trigger functions shown in the broadcast docs are inserting to.
Ohh i see now
Thanks!
Hi, I am trying realtime messages on postgres changes, I see them in Realtime inspector on the web, but my "listener" is not even joining.
What am I doing wrong?
This is my Python code:
The output:
On supabase web I see the listening working
