@@ -35,25 +35,45 @@ TStockWorkloadGenerator::TStockWorkloadGenerator(const TStockWorkloadParams* par
35
35
36
36
std::string TStockWorkloadGenerator::GetDDLQueries () const {
37
37
std::string stockPartitionsDdl = " " ;
38
- std::string ordersPartitionsDdl = " WITH (READ_REPLICAS_SETTINGS = \" per_az:1 \" ) " ;
38
+ std::string ordersPartitionsDdl = " " ;
39
39
std::string orderLinesPartitionsDdl = " " ;
40
- if (Params.PartitionsByLoad ) {
41
- stockPartitionsDdl = std::format (R"( WITH (
42
- AUTO_PARTITIONING_BY_LOAD = ENABLED
40
+
41
+ if (Params.GetStoreType () == TStockWorkloadParams::EStoreType::Row) {
42
+ ordersPartitionsDdl = " WITH (READ_REPLICAS_SETTINGS = \" per_az:1\" )" ;
43
+ if (Params.PartitionsByLoad ) {
44
+ stockPartitionsDdl = std::format (R"( WITH (
45
+ STORE = ROW
46
+ , AUTO_PARTITIONING_BY_LOAD = ENABLED
47
+ , AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = {0}
48
+ ))" , Params.MinPartitions );
49
+ ordersPartitionsDdl = std::format (R"( WITH (
50
+ STORE = ROW
51
+ , READ_REPLICAS_SETTINGS = "per_az:1"
52
+ , AUTO_PARTITIONING_BY_LOAD = ENABLED
53
+ , AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = {0}
54
+ , AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1000
55
+ , UNIFORM_PARTITIONS = {0}
56
+ ))" , Params.MinPartitions );
57
+ orderLinesPartitionsDdl = std::format (R"( WITH (
58
+ STORE = ROW
59
+ , AUTO_PARTITIONING_BY_LOAD = ENABLED
60
+ , AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = {0}
61
+ , AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1000
62
+ , UNIFORM_PARTITIONS = {0}
63
+ ))" , Params.MinPartitions );
64
+ }
65
+ } else {
66
+ stockPartitionsDdl = std::format (R"( WITH (
67
+ STORE = COLUMN
43
68
, AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = {0}
44
69
))" , Params.MinPartitions );
45
70
ordersPartitionsDdl = std::format (R"( WITH (
46
- READ_REPLICAS_SETTINGS = "per_az:1"
47
- , AUTO_PARTITIONING_BY_LOAD = ENABLED
71
+ STORE = COLUMN
48
72
, AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = {0}
49
- , AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1000
50
- , UNIFORM_PARTITIONS = {0}
51
73
))" , Params.MinPartitions );
52
74
orderLinesPartitionsDdl = std::format (R"( WITH (
53
- AUTO_PARTITIONING_BY_LOAD = ENABLED
75
+ STORE = COLUMN
54
76
, AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = {0}
55
- , AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1000
56
- , UNIFORM_PARTITIONS = {0}
57
77
))" , Params.MinPartitions );
58
78
}
59
79
@@ -66,11 +86,13 @@ std::string TStockWorkloadGenerator::GetDDLQueries() const {
66
86
}
67
87
68
88
return std::format (R"( --!syntax_v1
69
- CREATE TABLE `{0}/stock`(product Utf8, quantity Int64, PRIMARY KEY(product)) {1};
70
- CREATE TABLE `{0}/orders`(id Uint64, customer Utf8, created Datetime, processed Datetime, PRIMARY KEY(id), INDEX ix_cust GLOBAL ON (customer, created) COVER (processed) ) {2};
71
- CREATE TABLE `{0}/orderLines`(id_order Uint64, product Utf8, quantity Int64, PRIMARY KEY(id_order, product)) {3};
89
+ CREATE TABLE `{0}/stock`(product Utf8 {5} , quantity Int64, PRIMARY KEY(product)) {1};
90
+ CREATE TABLE `{0}/orders`(id Uint64 {5} , customer Utf8, created Datetime, processed Datetime, PRIMARY KEY(id) {6} ) {2};
91
+ CREATE TABLE `{0}/orderLines`(id_order Uint64 {5} , product Utf8 {5} , quantity Int64 {5} , PRIMARY KEY(id_order, product)) {3};
72
92
{4}
73
- )" , DbPath, stockPartitionsDdl, ordersPartitionsDdl, orderLinesPartitionsDdl, changefeeds);
93
+ )" , DbPath, stockPartitionsDdl, ordersPartitionsDdl, orderLinesPartitionsDdl, changefeeds,
94
+ Params.GetStoreType () == TStockWorkloadParams::EStoreType::Row ? " " : " NOT NULL" ,
95
+ Params.GetStoreType () == TStockWorkloadParams::EStoreType::Row ? " , INDEX ix_cust GLOBAL ON (customer, created) COVER (processed)" : " " );
74
96
}
75
97
76
98
TQueryInfoList TStockWorkloadGenerator::GetInitialData () {
@@ -205,15 +227,17 @@ TQueryInfo TStockWorkloadGenerator::ExecuteOrder(const uint64_t orderID) {
205
227
}
206
228
207
229
TQueryInfo TStockWorkloadGenerator::SelectCustomerHistory (const std::string& customerId, const unsigned int limit) {
208
- std::string query = R"( --!syntax_v1
209
- DECLARE $cust as Utf8;
210
- DECLARE $limit as UInt32;
211
- select id, customer, created
212
- from orders view ix_cust
213
- where customer = $cust
214
- order by customer desc, created desc
215
- limit $limit;
216
- )" ;
230
+ const std::string query = [this ]() {
231
+ return std::format (R"( --!syntax_v1
232
+ DECLARE $cust as Utf8;
233
+ DECLARE $limit as UInt32;
234
+ select id, customer, created
235
+ from orders {}
236
+ where customer = $cust
237
+ order by customer desc, created desc
238
+ limit $limit;
239
+ )" , Params.GetStoreType () == TStockWorkloadParams::EStoreType::Row ? " view ix_cust" : " " );
240
+ }();
217
241
218
242
NYdb::TParamsBuilder paramsBuilder;
219
243
paramsBuilder
@@ -304,6 +328,20 @@ TQueryInfoList TStockWorkloadGenerator::GetCustomerHistory() {
304
328
}
305
329
306
330
void TStockWorkloadParams::ConfigureOpts (NLastGetopt::TOpts& opts, const ECommandType commandType, int workloadType) {
331
+ auto addStorageTypeParam = [&]() {
332
+ opts.AddLongOption (" store" , " Storage type."
333
+ " Options: row, column\n "
334
+ " row - use row-based storage engine;\n "
335
+ " column - use column-based storage engine." )
336
+ .DefaultValue (StoreType)
337
+ .Handler1T <TStringBuf>([this ](TStringBuf arg) {
338
+ const auto l = to_lower (TString (arg));
339
+ if (!TryFromString (arg, StoreType)) {
340
+ throw yexception () << " Ivalid store type: " << arg;
341
+ }
342
+ });
343
+ };
344
+
307
345
switch (commandType) {
308
346
case TWorkloadParams::ECommandType::Init:
309
347
opts.AddLongOption (' p' , " products" , " Product count. Value in 1..500 000." )
@@ -318,8 +356,10 @@ void TStockWorkloadParams::ConfigureOpts(NLastGetopt::TOpts& opts, const EComman
318
356
.DefaultValue (true ).StoreResult (&PartitionsByLoad);
319
357
opts.AddLongOption (" enable-cdc" , " Create changefeeds on tables." )
320
358
.DefaultValue (false ).StoreTrue (&EnableCdc).Hidden ();
359
+ addStorageTypeParam ();
321
360
break ;
322
361
case TWorkloadParams::ECommandType::Run:
362
+ addStorageTypeParam ();
323
363
switch (static_cast <TStockWorkloadGenerator::EType>(workloadType)) {
324
364
case TStockWorkloadGenerator::EType::InsertRandomOrder:
325
365
case TStockWorkloadGenerator::EType::SubmitRandomOrder:
0 commit comments