Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: improve SapQueryRunner performance #10198

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 17 additions & 8 deletions src/driver/sap/SapQueryRunner.ts
Expand Up @@ -202,15 +202,24 @@ export class SapQueryRunner extends BaseQueryRunner implements QueryRunner {
const queryStartTime = +new Date()
const isInsertQuery = query.substr(0, 11) === "INSERT INTO"

statement = databaseConnection.prepare(query)
if (parameters?.some(Array.isArray)) {
lotczyk marked this conversation as resolved.
Show resolved Hide resolved
statement = await promisify(
databaseConnection.prepare.bind(databaseConnection),
)(query)
}

const raw = await new Promise<any>((ok, fail) => {
statement.exec(parameters, (err: any, raw: any) =>
err
? fail(new QueryFailedError(query, parameters, err))
: ok(raw),
)
})
let raw: any
try {
raw = statement
lotczyk marked this conversation as resolved.
Show resolved Hide resolved
? await promisify(statement.exec.bind(statement))(
parameters,
)
: await promisify(
databaseConnection.exec.bind(databaseConnection),
)(query, parameters, {})
} catch (err) {
throw new QueryFailedError(query, parameters, err)
}

// log slow queries if maxQueryExecution time is set
const maxQueryExecutionTime =
Expand Down