Write Queries
On this page
UPDATE
and DELETE
Queries
The WHERE
clause in an UPDATE
or DELETE
query is optimized the same way as the WHERE
clause in a SELECT
query.
INSERT
Queries
SingleStore executes INSERT
queries by analyzing the insert values relevant to the shard key and routing the query to the corresponding partition.INSERT INTO a (a1, a2, a3) VALUES (1, 2, 3)
would compute the hash value of (1, 2)
and map this value to the appropriate partition.
If you are bulk inserting data with INSERT
queries, then you should take advantage of the multi-insert syntax: INSERT INTO a (a1, a2, a3) VALUES (1, 2, 3), (2, 3, 4), .
.
When a multi-insert statement is executed, SingleStore uses two steps to commit the transaction:
-
Step one, where each leaf node validates their portion of the statement and acknowledges that they are ready to commit, and
-
Step two, where each leaf node actually commits the transaction.
Both steps are necessary to ensure that each leaf node partition successfully receives and executes their portion of the insert statement.
For example, consider a cluster with two leaf nodes and four partitions total.
Last modified: June 22, 2022