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)
do $db_open
# Hack to turn a SQLiteDatabase into a table
| $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
| query db "SELECT value FROM std_kv_store WHERE key = :key" --params { key: $key }
| match $in {
# Key not found
null => null
# Key found
_ => { from nuon }
# Match should be exactly one row
[$el] => { $el.value | from nuon }
# Otherwise no match
_ => null
}
}