MCPcopy Index your code
hub / github.com/riverqueue/river / InsertManyFastTx

Method InsertManyFastTx

client.go:2152–2158  ·  view source on GitHub ↗

InsertManyFastTx inserts many jobs at once using Postgres' `COPY FROM` mechanism, making the operation quite fast and memory efficient. Each job is inserted as an InsertManyParams tuple, which takes job args along with an optional set of insert options, which override insert options provided by an J

(ctx context.Context, tx TTx, params []InsertManyParams)

Source from the content-addressed store, hash-verified

2150// a unique constraint is violated, the operation will fail and no jobs will be
2151// inserted.
2152func (c *Client[TTx]) InsertManyFastTx(ctx context.Context, tx TTx, params []InsertManyParams) (int, error) {
2153 res, err := c.insertManyFast(ctx, c.driver.UnwrapExecutor(tx), params)
2154 if err != nil {
2155 return 0, err
2156 }
2157 return len(res), nil
2158}
2159
2160func (c *Client[TTx]) insertManyFast(ctx context.Context, execTx riverdriver.ExecutorTx, params []InsertManyParams) ([]*rivertype.JobInsertResult, error) {
2161 insertParams, err := c.insertManyParams(params)

Callers 1

Calls 2

insertManyFastMethod · 0.95
UnwrapExecutorMethod · 0.65

Tested by 1