Skip to content

Commit

Permalink
Reduced database notification payload (saurabhnanda#43)
Browse files Browse the repository at this point in the history
Because PostgreSQL limits notification payloads to 8000 bytes by
default, passing the full job record in the notification artificially
limits the job payload size.  By passing only required fields in the
notification, this limitation is removed.
  • Loading branch information
mrputty authored and philderbeast committed Apr 19, 2023
1 parent 3b1d25f commit 9b48e5b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/OddJobs/Migrations.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ createJobTableQuery tname = "CREATE TABLE " <> tname <>
createNotificationTrigger :: TableName -> Query
createNotificationTrigger tname = "create or replace function " <> fnName <> "() returns trigger as $$" <>
"begin \n" <>
" perform pg_notify('" <> pgEventName tname <> "', row_to_json(new)::text); \n" <>
" perform pg_notify('" <> pgEventName tname <> "', \n" <>
" json_build_object('id', new.id, 'run_at', new.run_at, 'locked_at', new.locked_at)::text); \n" <>
" return new; \n" <>
"end; \n" <>
"$$ language plpgsql;" <>
Expand Down

0 comments on commit 9b48e5b

Please sign in to comment.