Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 66c4031

Browse files
committed
Merge branch 'pgexplain-scan-direction' into 'master'
fix: do not lose scan direction when rendering EXPLAIN plan in textual format See merge request postgres-ai/joe!174
2 parents 9627741 + 6fbcae5 commit 66c4031

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

‎pkg/pgexplain/pgexplain.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,9 @@ func writePlanTextNodeCaption(outputFn func(string, ...interface{}) (int, error)
619619
parallel = "Parallel "
620620
}
621621

622-
outputFn("%s%v%s%s%s", parallel, nodeType, using, on, costsAndTiming)
622+
details := formatDetails(plan)
623+
624+
_, _ = outputFn("%s%v%s%s%s%s", parallel, nodeType, details, using, on, costsAndTiming)
623625
}
624626

625627
func writePlanTextNodeDetails(outputFn func(string, ...interface{}) (int, error), plan *Plan) {
@@ -741,3 +743,17 @@ func writePlanTextNodeDetails(outputFn func(string, ...interface{}) (int, error)
741743
outputFn("I/O Timings:%s", ioTiming)
742744
}
743745
}
746+
747+
func formatDetails(plan *Plan) string {
748+
var details []string
749+
750+
if plan.ScanDirection != "" && plan.ScanDirection != "Forward" {
751+
details = append(details, plan.ScanDirection)
752+
}
753+
754+
if len(details) > 0 {
755+
return fmt.Sprintf(" %v", strings.Join(details, ", "))
756+
}
757+
758+
return ""
759+
}

‎pkg/pgexplain/pgexplain_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ const InputJSON2 = `[
13091309
"Node Type": "Index Only Scan",
13101310
"Parent Relationship": "Outer",
13111311
"Parallel Aware": false,
1312-
"Scan Direction": "Forward",
1312+
"Scan Direction": "Backward",
13131313
"Index Name": "i_user_col",
13141314
"Relation Name": "table_1",
13151315
"Alias": "table_1",
@@ -1346,7 +1346,7 @@ const InputJSON2 = `[
13461346

13471347
const ExpectedText2 = ` Limit (cost=0.43..8.45 rows=1 width=22) (actual time=0.026..0.035 rows=1 loops=1)
13481348
Buffers: shared hit=4
1349-
-> Index Only Scan using i_user_col on table_1 (cost=0.43..8.45 rows=1 width=22) (actual time=0.021..0.026 rows=1 loops=1)
1349+
-> Index Only Scan Backward using i_user_col on table_1 (cost=0.43..8.45 rows=1 width=22) (actual time=0.021..0.026 rows=1 loops=1)
13501350
Index Cond: (col = 'xxxx'::text)
13511351
Heap Fetches: 0
13521352
Buffers: shared hit=4

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /