Repository navigation
Conversation
37ef3e8 to
3d2c0eb
Compare
| // associated serialization and download overhead. (Note: max_results = 0 | ||
| // is avoided because google-cloud-cpp's CreateKeysToFilterOut strips | ||
| // max_results from the JSON request if the value is <= 0). | ||
| query_request.set_max_results(1); |
There was a problem hiding this comment.
Please run TEST_P(HTAPIParameterizedTest, SQLExecDirect_with_pagination) with 1M rows and make sure all the values are returned.
There was a problem hiding this comment.
Done. I ran the test with 1M rows and our driver successfully fetched and validated all values for both standard and HTAPI runs.
Note: I had to remove the ORDER BY index clause to bypass a BigQuery memory limit error, and I updated the validation loop to extract row IDs dynamically. Notably, at this scale, the existing driver fails on the HTAPI run with a Stream removed error, but our driver handles it perfectly.
3d2c0eb to
e8e20fa
Compare
| bool bool_val = false; | ||
| std::transform(data.begin(), data.end(), data.begin(), ::tolower); | ||
| if (data == "1" || data == "true" || data == "yes") { | ||
| std::string lower_data = data; |
There was a problem hiding this comment.
why this change?, we are simply copying the lower_data = data and rest all is the same, isn't the output of bool same as the existing driver?
There was a problem hiding this comment.
The outer loop now uses a const std::string& to eliminate deep string copies for every cell. Because data is now immutable, we must make a local mutable copy (lower_data) specifically for booleans to use std::transform. This small tradeoff allows us to skip string copies entirely for all other data types.
| std::vector<BoundColInfo> bound_cols; | ||
| bound_cols.reserve(result_set.row_schema.size()); | ||
|
|
||
| SQLINTEGER bind_type = ard.GetHeaderRecord().bind_type; |
There was a problem hiding this comment.
can you please make this logic a function
be6e0a8 to
0ec5c17
Compare
|
Please rebase this with main and run the linux pipeline once. |
| // (or 10MB), returning a page_token to trigger HTAPI. This prevents | ||
| // BigQuery from spending 15+ seconds formatting massive JSON payloads, | ||
| // slashing TTFB. | ||
| query_request.set_max_results(100000); |
There was a problem hiding this comment.
Unless there is a clear justification wrt performance, we shouldn't hardcode this. I don't see us setting set_max_results = 1 on the driver before this. The page sizes depend on the number of columns. We shouldn't optimize based on he current behaviour of BQ services since the backend may change.
0ec5c17 to
03f4c75
Compare
03f4c75 to
9d0b2f5
Compare
2bf970c to
7b5b876
Compare
|
@Anshu6250 Please split this PR for |
|
Closing this PR as it is no longer relevant now. The updated optimizations and benchmarks have been addressed in #1714 (#1714). Thanks @sachinpro! |
Description
This PR significantly improves the data fetching and post-processing performance of the driver for both the JSON REST API (small datasets) and the Arrow HTAPI (large datasets). It addresses severe performance bottlenecks observed during
SQLBindColbenchmarks on 1 Million+ row queries and optimizes memory allocations during JSON response parsing.Changes
SQLBindColFetch Performance (odbc_sql_fetch.cc):GetBoundColumnshelper function, allowingWriteRowsetto pre-compute a cachedBoundColInfovector before iterating over rows.ard.HasDescriptorRecord()andard.GetDescriptorRecord()(which are O(log N)std::maplookups) for every single cell. For a 1 Million row query with 50 columns, this eliminated over 100 million redundant map lookups, bringingSQLBindColperformance on par withSQLGetData.WriteDSRowfunction.odbc_internal_commons.cc):ProcessResultSetRowsto utilizestd::move()when emplacingDSValuevariants into the row vector, preventing millions of deep buffer copies.std::stringcopies withstd::string const&inside the cell iteration loop.BQDataTypeschema lookups outside the row iteration loop.vector::reserve()calls to pre-allocate vector memory based on schema and result set sizes.max_results = 1with a balanced threshold to correctly route small results (<100k rows) to the ultra-fast JSON REST parser without apage_token, while securely deferring massive datasets to Arrow HTAPI without triggering data truncation test failures.benchmark_summary_linux.txt