sqlite: expose prepared statement statistics - #64541
Conversation
|
Review requested:
|
f5e8fcb to
2195e97
Compare
|
I'm a little uncomfortable with getters that create an object every time they're read. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #64541 +/- ##
=======================================
Coverage 90.23% 90.23%
=======================================
Files 739 739
Lines 241744 241770 +26
Branches 45552 45572 +20
=======================================
+ Hits 218136 218161 +25
- Misses 15148 15154 +6
+ Partials 8460 8455 -5
🚀 New features to boost your workflow:
|
bbbbeec to
bef2511
Compare
| {"run", SQLITE_STMTSTATUS_RUN}, | ||
| {"filterMiss", SQLITE_STMTSTATUS_FILTER_MISS}, | ||
| {"filterHit", SQLITE_STMTSTATUS_FILTER_HIT}, | ||
| {"memused", SQLITE_STMTSTATUS_MEMUSED}, |
There was a problem hiding this comment.
| {"memused", SQLITE_STMTSTATUS_MEMUSED}, | |
| {"memUsed", SQLITE_STMTSTATUS_MEMUSED}, |
There was a problem hiding this comment.
Since SQLite does not use an underscore here, I think memused is a more faithful name to the SQLite API.
There was a problem hiding this comment.
yeah, that was the pattern followed
Signed-off-by: geeksilva97 <edigleyssonsilva@gmail.com>
bef2511 to
fd5654c
Compare
|
Please @nodejs/sqlite , share your thoughts |
araujogui
left a comment
There was a problem hiding this comment.
Another method to reset stats would be nice to have
| {"reprepare", SQLITE_STMTSTATUS_REPREPARE}, | ||
| {"run", SQLITE_STMTSTATUS_RUN}, | ||
| {"filterMiss", SQLITE_STMTSTATUS_FILTER_MISS}, | ||
| {"filterHit", SQLITE_STMTSTATUS_FILTER_HIT}, |
There was a problem hiding this comment.
SQLITE_STMTSTATUS_FILTER_MISS and SQLITE_STMTSTATUS_FILTER_HIT was introduced in SQLite 3.38.0.
3.37.2: https://github.com/sqlite/sqlite/blob/version-3.37.2/src/sqlite.h.in
3.38.0: https://github.com/sqlite/sqlite/blob/version-3.38.0/src/sqlite.h.in
There was a problem hiding this comment.
So maybe we need to enforce a minimum SQLite version on --shared-sqlite
There was a problem hiding this comment.
Another method to reset stats would be nice to have
| ]; | ||
|
|
||
| test('returns a number for every valid counter', (t) => { | ||
| using db = new DatabaseSync(nextDb()); |
There was a problem hiding this comment.
| using db = new DatabaseSync(nextDb()); | |
| using db = new DatabaseSync(':memory:'); |
| return nullptr; | ||
| } | ||
|
|
||
| static constexpr const StatusInfo* GetStatusInfoFromName( |
There was a problem hiding this comment.
nit: This is structurally identical to GetLimitInfoFromName just above, we can replace both with a single function template.
template <typename T, size_t N>
static constexpr const T* FindByJsName(const std::array<T, N>& mapping,
std::string_view name) {
for (const auto& info : mapping) {
if (name == info.js_name) {
return &info;
}
}
return nullptr;
}
Closes #64540