Skip to content

Commit

Permalink
[YSQL] Fix single-row-txn detection after primary key change
Browse files Browse the repository at this point in the history
Summary:
D6326 (#955) implemented handling primary key as an index so that in can be used in an
index scan path.
As a side-effect it caused single-row inserts to be mis-categorized as multi-row operations
causing them to use the distributed txns path (instead of the single row txn path).
This fixes the relevant check.

Test Plan: java -jar ./target/yb-sample-apps.jar --workload SqlInserts --nodes 127.0.0.1:5433 --num_threads_write 24 --num_threads_read 0 --num_unique_keys 1000000000

Reviewers: robert

Reviewed By: robert

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D6437
  • Loading branch information
m-iancu committed Apr 4, 2019
1 parent 90680ca commit f2ecaa1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/postgres/src/backend/executor/nodeModifyTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,13 @@ ExecInsert(ModifyTableState *mtstate,
bool has_triggers = resultRelInfo->ri_TrigDesc &&
resultRelInfo->ri_TrigDesc->numtriggers > 0;

bool has_indices = resultRelInfo->ri_NumIndices > 1 ||
(resultRelInfo->ri_NumIndices == 1 &&
!resultRelInfo->ri_IndexRelationDescs[0]->rd_index
->indisprimary);

bool is_single_row_txn = estate->es_yb_is_single_row_modify_txn &&
resultRelInfo->ri_NumIndices == 0 &&
!has_indices &&
!has_triggers;

if (is_single_row_txn)
Expand Down

0 comments on commit f2ecaa1

Please sign in to comment.