Skip to content

Commit 5e8102f

Browse files
authored
Merge pull request neo4j#812 from oskarhane/pc-hits-in-profile
Add pagecache hits and misses to plan output
2 parents 904ed5e + 8782adb commit 5e8102f

File tree

3 files changed

+49
-10
lines changed

3 files changed

+49
-10
lines changed

e2e_tests/integration/plan.spec.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,20 @@
2323
describe('Plan output', () => {
2424
it('can connect', () => {
2525
const password = Cypress.env('browser-password') || 'newpassword'
26-
cy.connect('neo4j', password)
26+
cy.connect(
27+
'neo4j',
28+
password
29+
)
30+
})
31+
it('print pagecache stats in PROFILE', () => {
32+
cy.executeCommand(':clear')
33+
cy.executeCommand(
34+
`PROFILE MATCH (n:VendorId {{}uid: "d8eedae3ef0b4c45a9a27308", vendor: "run"}) RETURN n.uid, n.vendor, id(n)`
35+
)
36+
cy.get('[data-test-id="planExpandButton"]', { timeout: 10000 }).click()
37+
const el = cy.get('[data-test-id="planSvg"]', { timeout: 10000 })
38+
el.should('contain', 'pagecache hits')
39+
el.should('contain', 'pagecache misses')
2740
})
2841
it('ouputs and preselects plan when using PROFILE', () => {
2942
cy.executeCommand(':clear')
@@ -40,8 +53,7 @@ describe('Plan output', () => {
4053
LIMIT 50;`)
4154
cy.get('[data-test-id="planExpandButton"]', { timeout: 10000 }).click()
4255
const el = cy.get('[data-test-id="planSvg"]', { timeout: 10000 })
43-
el
44-
.should('contain', 'NodeByLabelScan')
56+
el.should('contain', 'NodeByLabelScan')
4557
.and('contain', 'tag')
4658
.and('contain', ':Tag')
4759
.and('contain', 'Filter')

src/browser/external/neoPlanner.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ neo.queryPlan = function(element) {
164164
(left =
165165
(left1 =
166166
operator.Expressions != null
167-
? operator.Expressions
168-
: operator.Expression != null
167+
? operator.Expressions
168+
: operator.Expression != null
169169
? operator.Expression
170170
: operator.LegacyExpression != null
171171
? operator.LegacyExpression
@@ -179,6 +179,19 @@ neo.queryPlan = function(element) {
179179
details.push({ className: 'padding' })
180180
}
181181

182+
if (operator.PageCacheHits || operator.PageCacheMisses) {
183+
details.push({
184+
className: 'pagecache-hits',
185+
key: 'pagecache hits',
186+
value: formatNumber(operator.PageCacheHits)
187+
})
188+
details.push({
189+
className: 'pagecache-misses',
190+
key: 'pagecache misses',
191+
value: formatNumber(operator.PageCacheMisses)
192+
})
193+
}
194+
182195
if (operator.Rows != null && operator.EstimatedRows != null) {
183196
details.push({
184197
className: 'estimated-rows',

src/shared/services/bolt/boltMappings.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,15 @@ export function extractPlan (result, calculateTotalDbHits = false) {
111111
Rows: plan.rows,
112112
identifiers: plan.identifiers,
113113
children: plan.children.map(_ => ({
114-
..._.arguments,
114+
...transformPlanArguments(_.arguments),
115115
...boltPlanToRESTPlanShared(_)
116116
}))
117117
}
118118
}
119-
let obj = { ...rawPlan.arguments, ...boltPlanToRESTPlanShared(rawPlan) }
119+
let obj = {
120+
...transformPlanArguments(rawPlan.arguments),
121+
...boltPlanToRESTPlanShared(rawPlan)
122+
}
120123

121124
if (calculateTotalDbHits === true) {
122125
obj.totalDbHits = collectHits(obj)
@@ -127,6 +130,17 @@ export function extractPlan (result, calculateTotalDbHits = false) {
127130
return null
128131
}
129132

133+
const transformPlanArguments = args => {
134+
const res = { ...args }
135+
if (res.PageCacheHits) {
136+
res.PageCacheHits = res.PageCacheHits.toNumber()
137+
}
138+
if (res.PageCacheMisses) {
139+
res.PageCacheMisses = res.PageCacheMisses.toNumber()
140+
}
141+
return res
142+
}
143+
130144
const collectHits = function (operator) {
131145
let hits = operator.DbHits || 0
132146
if (operator.children) {
@@ -279,9 +293,9 @@ export const retrieveFormattedUpdateStatistics = result => {
279293
.filter(field => stats[field.field] > 0)
280294
.map(
281295
field =>
282-
`${field.verb} ${stats[field.field]} ${stats[field.field] === 1
283-
? field.singular
284-
: field.plural}`
296+
`${field.verb} ${stats[field.field]} ${
297+
stats[field.field] === 1 ? field.singular : field.plural
298+
}`
285299
)
286300
return statsMessages.join(', ')
287301
} else return null

0 commit comments

Comments
 (0)