Cameron Hatfield commented on PHOENIX-6:
In general, the main use case I have is reducing RPC calls across
"compare-and-set" requests. A tertiary use case would be reducing the amount of
work the parser/compiler has to do (issuing and parsing one statement is
generally easier/faster then issuing and parsing multiple of the same
statements). The first could be handled by either supporting batching at the
client level (so one RPC call for multiple statements being run), though there
are questions on what autocommit means in that respect, or by supporting a
single statement that supports multiple values (such as a values statement that
supports multiple rows).
The allowing multiple statements for the same row key would basically be
equivalent to an "autocommit" after each individual statement, so that would
work for me.
> Support ON DUPLICATE KEY construct
> Key: PHOENIX-6
> URL: https://issues.apache.org/jira/browse/PHOENIX-6
> Project: Phoenix
> Issue Type: New Feature
> Reporter: James Taylor
> Assignee: James Taylor
> Fix For: 4.9.0
> Attachments: PHOENIX-6_wip1.patch
> To support inserting a new row only if it doesn't already exist, we should
> support the "on duplicate key" construct for UPSERT. With this construct, the
> UPSERT VALUES statement would run atomically and would thus require a read
> before write which would obviously have a negative impact on performance. For
> an example of similar syntax , see MySQL documentation at
> See this discussion for more detail:
> A related discussion is on PHOENIX-2909.
> Initially we'd support the following:
> # This would prevent the setting of VAL to 0 if the row already exists:
> UPSERT INTO T (PK, VAL) VALUES ('a',0)
> ON DUPLICATE KEY IGNORE;
> # This would increment the valueS of COUNTER1 and COUNTER2 if the row already
> exists and otherwise initialize them to 0:
> UPSERT INTO T (PK, COUNTER1, COUNTER2) VALUES ('a',0,0)
> ON DUPLICATE KEY UPDATE COUNTER1 = COUNTER1 + 1, COUNTER2 = COUNTER2 + 1;
> So the general form is:
> UPSERT ... VALUES ... [ ON DUPLICATE KEY [IGNORE | UPDATE
> <column>=<expression>, ...] ]
> The following restrictions will apply:
> - The <column> may not be part of the primary key constraint - only KeyValue
> columns will be allowed.
> To handle the maintenance of immutable indexes, we'll need to push the
> maintenance to the server side.
> This is because the mutations for indexes on immutable tables are calculated
> on the client-side, while this new syntax would potentially modify the value
> on the server-side.
This message was sent by Atlassian JIRA