@@ -35,25 +35,45 @@ TStockWorkloadGenerator::TStockWorkloadGenerator(const TStockWorkloadParams* par
3535
3636std::string TStockWorkloadGenerator::GetDDLQueries () const {
3737 std::string stockPartitionsDdl = " " ;
38- std::string ordersPartitionsDdl = " WITH (READ_REPLICAS_SETTINGS = \" per_az:1 \" ) " ;
38+ std::string ordersPartitionsDdl = " " ;
3939 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
4368 , AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = {0}
4469 ))" , Params.MinPartitions );
4570 ordersPartitionsDdl = std::format (R"( WITH (
46- READ_REPLICAS_SETTINGS = "per_az:1"
47- , AUTO_PARTITIONING_BY_LOAD = ENABLED
71+ STORE = COLUMN
4872 , AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = {0}
49- , AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1000
50- , UNIFORM_PARTITIONS = {0}
5173 ))" , Params.MinPartitions );
5274 orderLinesPartitionsDdl = std::format (R"( WITH (
53- AUTO_PARTITIONING_BY_LOAD = ENABLED
75+ STORE = COLUMN
5476 , AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = {0}
55- , AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1000
56- , UNIFORM_PARTITIONS = {0}
5777 ))" , Params.MinPartitions );
5878 }
5979
@@ -66,11 +86,13 @@ std::string TStockWorkloadGenerator::GetDDLQueries() const {
6686 }
6787
6888 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};
7292 {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)" : " " );
7496}
7597
7698TQueryInfoList TStockWorkloadGenerator::GetInitialData () {
@@ -205,15 +227,17 @@ TQueryInfo TStockWorkloadGenerator::ExecuteOrder(const uint64_t orderID) {
205227}
206228
207229TQueryInfo 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+ }();
217241
218242 NYdb::TParamsBuilder paramsBuilder;
219243 paramsBuilder
@@ -304,6 +328,20 @@ TQueryInfoList TStockWorkloadGenerator::GetCustomerHistory() {
304328}
305329
306330void 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+
307345 switch (commandType) {
308346 case TWorkloadParams::ECommandType::Init:
309347 opts.AddLongOption (' p' , " products" , " Product count. Value in 1..500 000." )
@@ -318,8 +356,10 @@ void TStockWorkloadParams::ConfigureOpts(NLastGetopt::TOpts& opts, const EComman
318356 .DefaultValue (true ).StoreResult (&PartitionsByLoad);
319357 opts.AddLongOption (" enable-cdc" , " Create changefeeds on tables." )
320358 .DefaultValue (false ).StoreTrue (&EnableCdc).Hidden ();
359+ addStorageTypeParam ();
321360 break ;
322361 case TWorkloadParams::ECommandType::Run:
362+ addStorageTypeParam ();
323363 switch (static_cast <TStockWorkloadGenerator::EType>(workloadType)) {
324364 case TStockWorkloadGenerator::EType::InsertRandomOrder:
325365 case TStockWorkloadGenerator::EType::SubmitRandomOrder:
0 commit comments