@@ -1043,6 +1043,71 @@ message PartitionResponse {
10431043// The request for [Read][google.spanner.v1.Spanner.Read] and
10441044// [StreamingRead][google.spanner.v1.Spanner.StreamingRead].
10451045message ReadRequest {
1046+ // An option to control the order in which rows are returned from a read.
1047+ enum OrderBy {
1048+ // Default value.
1049+ //
1050+ // ORDER_BY_UNSPECIFIED is equivalent to ORDER_BY_PRIMARY_KEY.
1051+ ORDER_BY_UNSPECIFIED = 0 ;
1052+
1053+ // Read rows are returned in primary key order.
1054+ //
1055+ // In the event that this option is used in conjunction with the
1056+ // `partition_token` field, the API will return an `INVALID_ARGUMENT` error.
1057+ ORDER_BY_PRIMARY_KEY = 1 ;
1058+
1059+ // Read rows are returned in any order.
1060+ ORDER_BY_NO_ORDER = 2 ;
1061+ }
1062+
1063+ // A lock hint mechanism for reads done within a transaction.
1064+ enum LockHint {
1065+ // Default value.
1066+ //
1067+ // LOCK_HINT_UNSPECIFIED is equivalent to LOCK_HINT_SHARED.
1068+ LOCK_HINT_UNSPECIFIED = 0 ;
1069+
1070+ // Acquire shared locks.
1071+ //
1072+ // By default when you perform a read as part of a read-write transaction,
1073+ // Spanner acquires shared read locks, which allows other reads to still
1074+ // access the data until your transaction is ready to commit. When your
1075+ // transaction is committing and writes are being applied, the transaction
1076+ // attempts to upgrade to an exclusive lock for any data you are writing.
1077+ // For more information about locks, see [Lock
1078+ // modes](https://cloud.google.com/spanner/docs/introspection/lock-statistics#explain-lock-modes).
1079+ LOCK_HINT_SHARED = 1 ;
1080+
1081+ // Acquire exclusive locks.
1082+ //
1083+ // Requesting exclusive locks is beneficial if you observe high write
1084+ // contention, which means you notice that multiple transactions are
1085+ // concurrently trying to read and write to the same data, resulting in a
1086+ // large number of aborts. This problem occurs when two transactions
1087+ // initially acquire shared locks and then both try to upgrade to exclusive
1088+ // locks at the same time. In this situation both transactions are waiting
1089+ // for the other to give up their lock, resulting in a deadlocked situation.
1090+ // Spanner is able to detect this occurring and force one of the
1091+ // transactions to abort. However, this is a slow and expensive operation
1092+ // and results in lower performance. In this case it makes sense to acquire
1093+ // exclusive locks at the start of the transaction because then when
1094+ // multiple transactions try to act on the same data, they automatically get
1095+ // serialized. Each transaction waits its turn to acquire the lock and
1096+ // avoids getting into deadlock situations.
1097+ //
1098+ // Because the exclusive lock hint is just a hint, it should not be
1099+ // considered equivalent to a mutex. In other words, you should not use
1100+ // Spanner exclusive locks as a mutual exclusion mechanism for the execution
1101+ // of code outside of Spanner.
1102+ //
1103+ // **Note:** Request exclusive locks judiciously because they block others
1104+ // from reading that data for the entire transaction, rather than just when
1105+ // the writes are being performed. Unless you observe high write contention,
1106+ // you should use the default of shared read locks so you don't prematurely
1107+ // block other clients from reading the data that you're writing to.
1108+ LOCK_HINT_EXCLUSIVE = 2 ;
1109+ }
1110+
10461111 // Required. The session in which the read should be performed.
10471112 string session = 1 [
10481113 (google.api.field_behavior ) = REQUIRED ,
@@ -1117,6 +1182,19 @@ message ReadRequest {
11171182 // If the field is set to `true` but the request does not set
11181183 // `partition_token`, the API returns an `INVALID_ARGUMENT` error.
11191184 bool data_boost_enabled = 15 ;
1185+
1186+ // Optional. Order for the returned rows.
1187+ //
1188+ // By default, Spanner will return result rows in primary key order except for
1189+ // PartitionRead requests. For applications that do not require rows to be
1190+ // returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting
1191+ // `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval,
1192+ // resulting in lower latencies in certain cases (e.g. bulk point lookups).
1193+ OrderBy order_by = 16 [(google.api.field_behavior ) = OPTIONAL ];
1194+
1195+ // Optional. Lock Hint for the request, it can only be used with read-write
1196+ // transactions.
1197+ LockHint lock_hint = 17 [(google.api.field_behavior ) = OPTIONAL ];
11201198}
11211199
11221200// The request for
0 commit comments