批量插入、修改或删除一个或多个表中的若干行数据。
BatchWriteRow 操作可视为多个 PutRow、UpdateRow、DeleteRow 操作的集合。各个操作独立执行,独立返回结果,独立计算服务能力单元。
与执行大量的单行写操作相比,使用 BatchWriteRow 操作可以有效减少请求的响应时间,提高数据的写入速率。
请求结构
message BatchWriteRowRequest {
repeated TableInBatchWriteRowRequest tables = 1;
}
请求参数
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
tables | repeated TableInBatchWriteRowRequest | 是 |
指定了需要要执行写操作的行信息。 以下情况都会返回整体错误:
|
响应消息结构
message BatchWriteRowResponse {
repeated TableInBatchWriteRowResponse tables = 1;
}
响应参数
参数 | 类型 | 描述 |
---|---|---|
tables | TableInBatchWriteRowResponse |
对应了每个 table 下各操作的响应信息,包括是否成功执行,错误码和消耗的服务能力单元。 响应消息中 TableInBatchWriteRowResponse 对象的顺序与 BatchWriteRowRequest 中的 TableInBatchWriteRowRequest 对象的顺序相同;每个 TableInBatchWriteRowRequest 中 put_rows、update_rows、delete_rows 包含的 RowInBatchWriteRowResponse 对象的顺序分别与 TableInBatchWriteRowRequest 中 put_rows、update_rows、delete_rows 包含的 PutRowInBatchWriteRowRequest、UpdateRowInBatchWriteRowRequest 和 DeleteRowInBatchWriteRowRequest 对象的顺序相同。 若某行读取失败,该行所对应的 RowInBatchWriteRowResponse 中 is_ok 将为 false。 |
服务能力单元消耗
- 如果本次操作整体失败,不消耗任何服务能力单元。
- 如果请求超时,结果未定义,服务能力单元有可能被消耗,也可能未被消耗。
- 其他情况将每个 PutRowInBatchWriteRowRequest、UpdateRowInBatchWriteRowRequestDelete、RowInBatchWriteRowRequest 依次视作相对应的写操作独立计算读服务能力单元。请参考PutRow 服务能力单元消耗,UpdateRow 服务能力单元消耗和DeleteRow 服务能力单元消耗。