Skip to content

Commit

Permalink
work around incorrect row counts for large in plan view (#1938)
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarDamkjaer authored Sep 14, 2023
1 parent 1171dce commit 7973dee
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/shared/services/bolt/boltMappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,26 @@ export function extractPlan(result: any, calculateTotalDbHits = false) {
if (result.summary && (result.summary.plan || result.summary.profile)) {
const rawPlan = result.summary.profile || result.summary.plan
const boltPlanToRESTPlanShared = (plan: any) => {
// `dbHits` and `Rows` are available both on the plan object and on plan.arguments
// there is a bug numbers that are larger than signed 32 bit integers overflow and become negative
// if we find that the value on arguments is available and above the max signed 32 bit integer
// we do a workaround and use that instead. Otherwise we prefer the original value

// sidenote: It is called "dbHits" in the plan object and "DbHits" in plan.arguments,
// it's not a typo, just a little confusing
const SIGNED_INT32_MAX = 2147483647
return {
operatorType: plan.operatorType,
DbHits: plan.dbHits,
Rows: plan.rows,
DbHits:
plan?.arguments?.DbHits?.toNumber() > SIGNED_INT32_MAX
? plan?.arguments?.DbHits?.toNumber()
: plan.dbHits,

Rows:
plan?.arguments?.Rows?.toNumber() > SIGNED_INT32_MAX
? plan?.arguments?.Rows?.toNumber()
: plan.rows,

identifiers: plan.identifiers,
children: plan.children.map((_: any) => ({
...transformPlanArguments(_.arguments),
Expand Down

0 comments on commit 7973dee

Please sign in to comment.