[PATCH] box: account index.pairs in box.stat.SELECT
Vladimir Davydov
vdavydov.dev at gmail.com
Thu Apr 11 22:44:25 MSK 2019
box.stat.SELECT accounts index.get and index.select, but not
index.pairs, which is confusing since pairs() may be used even
more often than select() in a Lua application.
---
https://github.com/tarantool/tarantool/commits/dv/account-pairs-in-stat-select
src/box/index.cc | 1 +
test/box/stat.result | 39 +++++++++++++++++++++++++++++++++++++++
test/box/stat.test.lua | 12 ++++++++++++
3 files changed, 52 insertions(+)
diff --git a/src/box/index.cc b/src/box/index.cc
index 3c53ae81..2817d076 100644
--- a/src/box/index.cc
+++ b/src/box/index.cc
@@ -380,6 +380,7 @@ box_index_iterator(uint32_t space_id, uint32_t index_id, int type,
return NULL;
}
txn_commit_ro_stmt(txn);
+ rmean_collect(rmean_box, IPROTO_SELECT, 1);
return it;
}
diff --git a/test/box/stat.result b/test/box/stat.result
index af1607db..757ec0bc 100644
--- a/test/box/stat.result
+++ b/test/box/stat.result
@@ -70,6 +70,45 @@ box.stat.ERROR.total
---
- 1
...
+-- select, get, and pairs
+space:get(1)
+---
+- [1, 'tuple1']
+...
+box.stat.SELECT.total
+---
+- 5
+...
+space:get(11)
+---
+...
+box.stat.SELECT.total
+---
+- 6
+...
+space:select(5)
+---
+- - [5, 'tuple5']
+...
+box.stat.SELECT.total
+---
+- 7
+...
+space:select(15)
+---
+- []
+...
+box.stat.SELECT.total
+---
+- 8
+...
+for _ in space:pairs() do end
+---
+...
+box.stat.SELECT.total
+---
+- 9
+...
-- reset
box.stat.reset()
---
diff --git a/test/box/stat.test.lua b/test/box/stat.test.lua
index 65555127..6ee1ec44 100644
--- a/test/box/stat.test.lua
+++ b/test/box/stat.test.lua
@@ -26,6 +26,18 @@ box.stat.SELECT.total
space:get('Impossible value')
box.stat.ERROR.total
+-- select, get, and pairs
+space:get(1)
+box.stat.SELECT.total
+space:get(11)
+box.stat.SELECT.total
+space:select(5)
+box.stat.SELECT.total
+space:select(15)
+box.stat.SELECT.total
+for _ in space:pairs() do end
+box.stat.SELECT.total
+
-- reset
box.stat.reset()
box.stat.INSERT.total
--
2.11.0
More information about the Tarantool-patches
mailing list