Hacker News new | ask | show | jobs
by kiwicopple 2350 days ago
I took a lot of inspiration from Hasura and Debezium. At the time they used triggers to send events via NOTIFY (not sure if they still do)

The issue with NOTIFY is that it has an 8000 byte limit. Some of our updates are large (JSONB columns) so we need more than 8000 bytes, or we would have to notify just the row identifier, then fetch the data (inefficient).

Supabase hooks in to Postgres' replication stream so there is no issue. It converts the streaming bytes to JSON.

One other bonus - you don't have to set a trigger on every table. Just run `CREATE PUBLICATION supabase_realtime ON ALL TABLES`, then you're good to go.

2 comments

Debezium uses neither triggers nor NOTIFY. For Postgres, it uses one of several supported logical decoding plug-ins (pgoutput, decoderbufs, wal2json), which doesn't have any size limit and also allow to capture changes occuring while it isn't running by catching up with changes from the WAL from the point where it left off before.

Disclaimer: Debezium lead here

That makes a lot of sense. Tempted to try this out now. If people would just stop coming up with all those really interesting projects, that'd be great. At some point I should probably get some actual work done...