feat(gaussdb): make count query parallelism configurable
This commit is contained in:
1 parent
4ce27f8ae5
commit
f6b91e93dc
16 files changed
+235
-3
No files matched your search
@@ -11,11 +11,14 @@ import {
|
||||
connectionUsesDatabaseObjectTreeMode,
|
||||
effectiveDatabaseTypeForConnection,
|
||||
gaussdbConnectionMode,
|
||||
gaussdbCountQueryDop,
|
||||
gaussdbCountQueryDopHint,
|
||||
gaussdbIdentifierQuoteOverride,
|
||||
gaussdbIdentifierQuoteStyle,
|
||||
gaussdbTargetServerType,
|
||||
inferJdbcDialect,
|
||||
setGaussdbConnectionMode,
|
||||
setGaussdbCountQueryDop,
|
||||
setGaussdbIdentifierQuoteStyle,
|
||||
setGaussdbTargetServerType,
|
||||
supportsGaussdbIdentifierQuoteStyle,
|
||||
@@ -236,6 +239,24 @@ describe("GaussDB connection mode", () => {
|
||||
expect(gaussdbTargetServerType(connection)).toBe("any");
|
||||
expect(connection.external_config).toEqual({ gaussdbTargetServerType: "any" });
|
||||
});
|
||||
|
||||
it("keeps count query parallelism disabled until explicitly configured", () => {
|
||||
const connection = { db_type: "gaussdb", external_config: { retained: true } } as ConnectionConfig;
|
||||
|
||||
expect(gaussdbCountQueryDop(connection)).toBe(1);
|
||||
expect(gaussdbCountQueryDopHint(connection)).toBeUndefined();
|
||||
|
||||
setGaussdbCountQueryDop(connection, 8);
|
||||
expect(connection.external_config).toEqual({ retained: true, gaussdbCountQueryDop: 8 });
|
||||
expect(gaussdbCountQueryDopHint(connection)).toBe("/*+ set(query_dop 8) */");
|
||||
|
||||
connection.external_config = { retained: true, gaussdbCountQueryDop: 32 };
|
||||
expect(gaussdbCountQueryDop(connection)).toBe(1);
|
||||
expect(gaussdbCountQueryDopHint(connection)).toBeUndefined();
|
||||
|
||||
setGaussdbCountQueryDop(connection, 1);
|
||||
expect(connection.external_config).toEqual({ retained: true });
|
||||
});
|
||||
});
|
||||
|
||||
describe("query execution schema", () => {
|
||||
|
||||
@@ -108,6 +108,9 @@ export interface DataGridCountSqlOptions {
|
||||
schema?: string;
|
||||
tableName: string;
|
||||
whereInput?: string;
|
||||
/** Optional optimizer hint injected between SELECT and the select list.
|
||||
* Example: "/*+ set(query_dop 32) */" for GaussDB parallel COUNT(*). */
|
||||
countHint?: string;
|
||||
}
|
||||
|
||||
export interface HiveTablePropertiesSqlOptions {
|
||||
|
||||
@@ -7,9 +7,11 @@ type JdbcDialectConnection = Partial<Pick<ConnectionConfig, "db_type" | "driver_
|
||||
export type GaussdbIdentifierQuoteStyle = "auto" | "double" | "backtick";
|
||||
export type GaussdbConnectionMode = "native" | "m-jdbc";
|
||||
export type GaussdbTargetServerType = "master" | "slave" | "any";
|
||||
export type GaussdbCountQueryDop = 1 | 2 | 4 | 8 | 16;
|
||||
|
||||
const GAUSSDB_IDENTIFIER_QUOTE_STYLE_KEY = "gaussdbIdentifierQuoteStyle";
|
||||
const GAUSSDB_TARGET_SERVER_TYPE_KEY = "gaussdbTargetServerType";
|
||||
const GAUSSDB_COUNT_QUERY_DOP_KEY = "gaussdbCountQueryDop";
|
||||
export const GAUSSDB_M_JDBC_DRIVER_PROFILE = "gaussdb-m";
|
||||
export const GAUSSDB_M_JDBC_DRIVER_CLASS = "com.huawei.gaussdb.jdbc.Driver";
|
||||
|
||||
@@ -239,6 +241,27 @@ export function codeMirrorSqlDialectForConnection(connection?: JdbcDialectConnec
|
||||
return codeMirrorSqlDialect(databaseType);
|
||||
}
|
||||
|
||||
export function gaussdbCountQueryDop(connection: JdbcDialectConnection | undefined): GaussdbCountQueryDop {
|
||||
const external = externalConfigRecord(connection?.external_config);
|
||||
const value = external[GAUSSDB_COUNT_QUERY_DOP_KEY];
|
||||
return value === 2 || value === 4 || value === 8 || value === 16 ? value : 1;
|
||||
}
|
||||
|
||||
export function setGaussdbCountQueryDop(connection: Pick<ConnectionConfig, "db_type"> & Partial<Pick<ConnectionConfig, "external_config">>, value: GaussdbCountQueryDop) {
|
||||
const external = externalConfigRecord(connection.external_config);
|
||||
if (value === 1) {
|
||||
delete external[GAUSSDB_COUNT_QUERY_DOP_KEY];
|
||||
} else {
|
||||
external[GAUSSDB_COUNT_QUERY_DOP_KEY] = value;
|
||||
}
|
||||
connection.external_config = Object.keys(external).length > 0 ? external : undefined;
|
||||
}
|
||||
|
||||
export function gaussdbCountQueryDopHint(connection: JdbcDialectConnection | undefined): string | undefined {
|
||||
const dop = gaussdbCountQueryDop(connection);
|
||||
return dop > 1 ? `/*+ set(query_dop ${dop}) */` : undefined;
|
||||
}
|
||||
|
||||
function isJdbcAseProfile(connection?: JdbcDialectConnection): boolean {
|
||||
if (connection?.db_type !== "jdbc") return false;
|
||||
const explicitIdentity = [connection.driver_profile, connection.driver_label, connection.database_info?.productName].filter(Boolean).join("\n");
|
||||
|
||||
Reference in new issue
Block a user