Skip to content

Commit

Permalink
[AD-758] - Performance investigation SELECT * TABLE and SELECT * VIRT…
Browse files Browse the repository at this point in the history
…UAL-TABLE (#84)

This fixes some issues.

Warning console messages while querying.
The performance framework was not cleaning up bind_fetch vector.
Split between bind and fetch time in the performance framework
added default batch fetch size.
  • Loading branch information
affonsov authored Jun 23, 2022
1 parent b4651f8 commit a7e352e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/odbc/src/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,11 @@ std::string Connection::FormatMongoCppConnectionString(
mongoConnectionString.append("@" + host);
mongoConnectionString.append(":" + port);
mongoConnectionString.append("/admin");
mongoConnectionString.append("?authMechanism=SCRAM-SHA-1");
if (config_.IsTls()) {
mongoConnectionString.append("?tlsAllowInvalidHostnames=true");
mongoConnectionString.append("&tlsAllowInvalidHostnames=true");
}

// tls configuration is handled using tls_options in connectionCPP
// TODO handle the other DSN configuration
// https://bitquill.atlassian.net/browse/AD-599
Expand Down
4 changes: 3 additions & 1 deletion src/odbc/src/query/data_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ SqlResult::Type DataQuery::MakeRequestFetch() {
for (auto const& stage : aggregateOperations) {
pipeline.append_stage(bsoncxx::from_json(stage));
}
mongocxx::cursor cursor = collection.aggregate(pipeline);
auto options = mongocxx::options::aggregate{};
options.batch_size(config.GetDefaultFetchSize());
mongocxx::cursor cursor = collection.aggregate(pipeline, options);

this->cursor_.reset(new DocumentDbCursor(cursor, columnMetadata, paths));

Expand Down
2 changes: 2 additions & 0 deletions src/tests/performance/include/performance_test_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ struct TestCase {
std::vector< long long > time_ms; // time for exec->bind->fetch combined
std::vector< long long > time_exec_ms;
std::vector< long long > time_bind_fetch_ms;
std::vector< long long > time_bind_ms;
std::vector< long long > time_fetch_ms;
StatisticalInfo stat_info;
StatisticalInfo stat_info_exec;
StatisticalInfo stat_info_bind_fetch;
Expand Down
45 changes: 39 additions & 6 deletions src/tests/performance/src/performance_test_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ void performance::PerformanceTestRunner::RecordExecBindFetch(
SQLROWSETSIZE row_count;
long long time_exec_ms;
long long time_bind_fetch_ms;
long long time_bind_ms;
long long time_fetch_ms;
std::vector< Col > cols;

// Query
Expand Down Expand Up @@ -450,7 +452,7 @@ void performance::PerformanceTestRunner::RecordExecBindFetch(
}

// Bind and fetch and record time
auto time_bind_fetch_start = std::chrono::steady_clock::now();
auto time_bind_start = std::chrono::steady_clock::now();
for (size_t i = 0; i < static_cast< size_t >(total_columns); i++) {
ret = SQLBindCol(*hstmt, static_cast< SQLUSMALLINT >(i + 1), SQL_C_CHAR,
static_cast< SQLPOINTER >(&cols[i].data_dat[0]),
Expand All @@ -462,18 +464,28 @@ void performance::PerformanceTestRunner::RecordExecBindFetch(
return; // continue to next test case
}
}
auto time_bind_end = std::chrono::steady_clock::now();

auto time_fetch_start = std::chrono::steady_clock::now();
while (SQLFetch(*hstmt) == SQL_SUCCESS) {
row_count++;
}
auto time_fetch_end = std::chrono::steady_clock::now();

auto time_bind_fetch_end = std::chrono::steady_clock::now();
// Store bind and fetch time
time_bind_ms = std::chrono::duration_cast< std::chrono::milliseconds >(
time_bind_end - time_bind_start)
.count();
test_case.time_bind_ms.push_back(time_bind_ms);

// Store bind and fetch time
time_fetch_ms = std::chrono::duration_cast< std::chrono::milliseconds >(
time_fetch_end - time_fetch_start)
.count();
test_case.time_fetch_ms.push_back(time_fetch_ms);

// Store bind and fetch time
time_bind_fetch_ms =
std::chrono::duration_cast< std::chrono::milliseconds >(
time_bind_fetch_end - time_bind_fetch_start)
.count();
time_bind_fetch_ms = time_bind_ms + time_fetch_ms;
test_case.time_bind_fetch_ms.push_back(time_bind_fetch_ms);

test_case.time_ms.push_back(time_exec_ms + time_bind_fetch_ms);
Expand Down Expand Up @@ -646,6 +658,22 @@ void performance::PerformanceTestRunner::ReportTime(const TestCase& test_case) {
}
std::cout << "\n\n";

std::cout << "SQLBindCol time dump: ";
for (size_t i = 0; i < test_case.time_bind_ms.size(); i++) {
std::cout << test_case.time_bind_ms[i] << " ms";
if (i != (test_case.time_bind_ms.size() - 1))
std::cout << ", ";
}
std::cout << "\n\n";
std::cout << "SQLFetch time dump: ";
for (size_t i = 0; i < test_case.time_fetch_ms.size(); i++) {
std::cout << test_case.time_fetch_ms[i] << " ms";
if (i != (test_case.time_fetch_ms.size() - 1))
std::cout << ", ";
}

std::cout << "\n\n";

} else if (_output_mode == 2) {
std::cout << sync_min << test_case.stat_info_bind_fetch.min << " ms"
<< std::endl;
Expand Down Expand Up @@ -981,6 +1009,11 @@ void performance::PerformanceTestRunner::RunPerformanceTestPlan() {
test_case.test_name.clear();
test_case.time_ms.clear();

test_case.time_exec_ms.clear();
test_case.time_bind_fetch_ms.clear();
test_case.time_bind_ms.clear();
test_case.time_fetch_ms.clear();

// Deallocate Statement Handle
if (SQL_NULL_HSTMT != _hstmt) {
CloseCursor(&_hstmt, true, true);
Expand Down

0 comments on commit a7e352e

Please sign in to comment.