std-rfc/kv: optimize kv get by only selecting one row from the stor db (#15792)

Optimize std-rfc/kv, kv get to only read one row from the sqlite db.
This commit is contained in:
Ville Vainio 2025-05-23 04:14:31 +03:00 committed by GitHub
parent 7c50f7c714
commit 88d421dcb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -111,16 +111,12 @@ export def "kv get" [
] { ] {
let db_open = (db_setup --universal=$universal) let db_open = (db_setup --universal=$universal)
do $db_open do $db_open
# Hack to turn a SQLiteDatabase into a table | query db "SELECT value FROM std_kv_store WHERE key = :key" --params { key: $key }
| $in.std_kv_store | wrap temp | get temp
| where key == $key
# Should only be one occurrence of each key in the stor
| get -i value.0
| match $in { | match $in {
# Key not found # Match should be exactly one row
null => null [$el] => { $el.value | from nuon }
# Key found # Otherwise no match
_ => { from nuon } _ => null
} }
} }