diff --git a/include/snowflake/client.h b/include/snowflake/client.h index e7c2d930ea..314d84b900 100644 --- a/include/snowflake/client.h +++ b/include/snowflake/client.h @@ -498,6 +498,7 @@ typedef struct SF_CONNECT { sf_bool binding_threshold_overridden; sf_bool stage_binding_disabled; sf_bool disable_console_login; + uint8 prefetch_threads; sf_bool client_store_temporary_credential; } SF_CONNECT; diff --git a/lib/client.c b/lib/client.c index 9aacab550f..c5afdd96ca 100644 --- a/lib/client.c +++ b/lib/client.c @@ -379,6 +379,9 @@ static SF_STATUS STDCALL _reset_connection_parameters( !sf->binding_threshold_overridden) { sf->stage_binding_threshold = snowflake_cJSON_GetUint64Value(value); } + else if (strcmp(name->valuestring, "CLIENT_PREFETCH_THREADS") == 0) { + sf->prefetch_threads = snowflake_cJSON_GetUint64Value(value); + } } } SF_STATUS ret = SF_STATUS_ERROR_GENERAL; @@ -836,6 +839,7 @@ _snowflake_check_connection_parameters(SF_CONNECT *sf) { log_debug("get_fastfail: %s", sf->get_fastfail ? "true" : "false"); log_debug("get_maxretries: %d", sf->get_maxretries); log_debug("get_threshold: %d", sf->get_threshold); + log_debug("prefetch_threads: %d", sf->prefetch_threads); return SF_STATUS_SUCCESS; } @@ -1084,7 +1088,7 @@ SF_CONNECT *STDCALL snowflake_init() { _mutex_init(&sf->mutex_stage_bind); sf->binding_stage_created = SF_BOOLEAN_FALSE; sf->stage_binding_threshold = SF_DEFAULT_STAGE_BINDING_THRESHOLD; - + sf->prefetch_threads = SF_DEFAULT_PREFETCH_THREAD; sf->sso_token = NULL; sf->mfa_token = NULL; } @@ -1962,8 +1966,8 @@ static sf_bool setup_result_with_json_resp(SF_STMT* sfstmt, cJSON* data) qrmk, chunk_headers, chunks, - 2, // thread count - 4, // fetch slot + sfstmt->connection->prefetch_threads, // thread count + sfstmt->connection->prefetch_threads * 2, // fetch slot &sfstmt->error, sfstmt->connection->insecure_mode, sfstmt->connection->ocsp_fail_open, diff --git a/lib/client_int.h b/lib/client_int.h index ce374dd5a1..816875073a 100644 --- a/lib/client_int.h +++ b/lib/client_int.h @@ -32,6 +32,7 @@ #define SF_DEFAULT_GET_MAX_RETRIES 5 #define SF_MAX_GET_MAX_RETRIES 100 #define SF_DEFAULT_GET_THRESHOLD 5 +#define SF_DEFAULT_PREFETCH_THREAD 4 #define SESSION_URL "/session/v1/login-request" #define QUERY_URL "/queries/v1/query-request"