Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] Batch writes (inserts / updates / deletes) #2934

Closed
ndeodhar opened this issue Nov 14, 2019 · 0 comments
Closed

[YSQL] Batch writes (inserts / updates / deletes) #2934

ndeodhar opened this issue Nov 14, 2019 · 0 comments
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) priority/high High Priority
Milestone

Comments

@ndeodhar
Copy link
Contributor

Today, when we have an update/delete statement like:
update foo set x=value where condition
or
delete from foo where x=value
we first read all rows that satisfy the condition and then send 1 update/delete tserver write request per row. We should batch those write requests to make it more performant.

@ndeodhar ndeodhar added the area/ysql Yugabyte SQL (YSQL) label Nov 14, 2019
@ndeodhar ndeodhar added this to the v2.1 milestone Nov 14, 2019
@ndeodhar ndeodhar added the priority/high High Priority label Nov 16, 2019
d-uspenskiy added a commit that referenced this issue Feb 10, 2020
Summary:
Enable buffering of write operation in each SQL statement.

1. Write operation buffering is started at the beginning of each statement (StartTransactionCommand function). Buffered operations are flushed at the successful end of statement  (CommitTransactionCommand function). In case transaction is aborted nothing happens with buffered operations. They will be silently dropped at the beginning of next statement (on buffering start).

2. All buffered operations also will be flushed on each attempt to perform non-bufferable operation (operations which result required immediately). They are all read operations and write operations with `force_non_bufferable` flag set to true.

3. For now DocDB can't process multiple write operations related to same row id in single RPC. Second operation will not see the results of first one. As a result it is possible to insert multiple non-unique values into column with  unique constraint. Now it is handled by flashing all buffered operations before processing new one in case it relates to already affected row id.

4. Buffered operation can produce `duplicate key value violates unique constraint` error. Description of this message required constraint name. For this purpose each operation stores postgres relation id. Also  interface with `C` callbacks is introduced. `PgSession` object calls `FetchUniqueConstraintName` callback with relation id to get violated constraint name.

5. Buffered operations can produce ERROR description with irrelevant CONTEXT part. Separate issue #3528 is created for this problem. For now printing of CONTEXT part is suppressed.

Test Plan:
New test case is implemented

```
./yb_build.sh --java-test org.yb.pgsql.TestOperationBatching
```

Reviewers: mikhail, neha, alex

Reviewed By: neha, alex

Subscribers: neha, alex, yql

Differential Revision: https://phabricator.dev.yugabyte.com/D7782
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) priority/high High Priority
Projects
None yet
Development

No branches or pull requests

2 participants