fix(highgo): paginate queries via limit offset for performance

This commit is contained in:
amwps290 authored and GitHub committed 2026-08-30 09:59:24 +08:00
1 parent 5a11b8f148
commit 469bd88c37
3 files changed
+138 -11

No files matched your search

+18 -1
View File
@@ -505,6 +505,13 @@ enum TableExportCursorKind {
ExternalDriver,
}
fn table_export_cursor_allowed(database_type: DatabaseType, cursor_kind: TableExportCursorKind) -> bool {
// HighGo's JDBC driver may materialize the complete unbounded result before
// startTableRead can return its first cursor page. Use the existing bounded
// keyset/LIMIT-OFFSET table export path instead.
database_type != DatabaseType::Highgo || cursor_kind != TableExportCursorKind::Agent
}
#[derive(Clone, Debug, PartialEq, Eq)]
enum TableExportCursorSession {
Agent(String),
@@ -652,7 +659,10 @@ async fn fetch_table_export_batch(
}
if !*table_read_attempted {
match table_export_cursor_kind(state, pool_key).await {
let cursor_kind = table_export_cursor_kind(state, pool_key)
.await
.filter(|cursor_kind| table_export_cursor_allowed(*db_type, *cursor_kind));
match cursor_kind {
Some(TableExportCursorKind::Agent) => {
*table_read_attempted = true;
let sql = table_cursor_sql(request, sql_context, query_col_names, column_types, primary_keys);
@@ -2348,6 +2358,13 @@ mod tests {
assert_eq!(format_tsv_rows(&rows), "");
}
#[test]
fn highgo_table_export_avoids_unbounded_agent_cursor() {
assert!(!table_export_cursor_allowed(DatabaseType::Highgo, TableExportCursorKind::Agent));
assert!(table_export_cursor_allowed(DatabaseType::Highgo, TableExportCursorKind::ExternalDriver));
assert!(table_export_cursor_allowed(DatabaseType::Oracle, TableExportCursorKind::Agent));
}
#[test]
fn export_batch_size_respects_row_limit_remaining_rows() {
assert_eq!(next_export_batch_size(None, 12_000, 10_000), Some(10_000));