supabase / realtime

Broadcast, Presence, and Postgres Changes via WebSockets
https://supabase.com/realtime
Apache License 2.0
6.83k stars 315 forks source link

Batch messages sent to subscribers #301

Open AntonOfTheWoods opened 2 years ago

AntonOfTheWoods commented 2 years ago

Feature request

In order to allow for efficient updates to subscribers when hundreds/thousands of db rows are inserted/updated, it would be preferable to have subscriptions capable of being fed with bulk updates, rather than a separate message for each row inserted/changed.

Is your feature request related to a problem? Please describe.

I have a bulk import feature and the changed entries need to be pushed to all devices in real time. The entries would be stored locally (via rxdb) and need to be kept in sync.

Describe the solution you'd like

The push messages for the subscriptions should be able to contain all the rows affected from a single insert/upsert/update/delete transaction.

Describe alternatives you've considered

Create a "bulk_updated" table that could receive updates with a table name, which would then cause the local store to disconnect for that particular table, download the full diff, then reconnect for realtime (single row) updates again.

chasers commented 1 year ago

@AntonOfTheWoods thanks for this!

I think the workaround here would actually work very well.

But it would definitely be nice for Realtime to automatically batch stuff for you when needed. I updated the title to reflect this a bit better.