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)
| 2150 | // a unique constraint is violated, the operation will fail and no jobs will be |
| 2151 | // inserted. |
| 2152 | func (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 | |
| 2160 | func (c *Client[TTx]) insertManyFast(ctx context.Context, execTx riverdriver.ExecutorTx, params []InsertManyParams) ([]*rivertype.JobInsertResult, error) { |
| 2161 | insertParams, err := c.insertManyParams(params) |