# nk.storageRead performance compare

**URL:** <https://forum.heroiclabs.com/t/nk-storageread-performance-compare/5806>\
**Category:** Runtime Framework\
**Tags:** server-framework\
**Created:** [November 14, 2024, 5:46pm UTC](https://forum.heroiclabs.com/t/nk-storageread-performance-compare/5806 "2024-11-14T17:46:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mengxin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/mengxin/32/1879_2.png) [@mengxin](https://forum.heroiclabs.com/u/mengxin)\
**Post date:** [November 14, 2024, 5:46pm UTC](https://forum.heroiclabs.com/t/nk-storageread-performance-compare/5806/1 "2024-11-14T17:46:51Z")

</div>

We understand that nk.storageRead supports multiple read requests simultaneously. However, if we split each request and invoke nk.storageRead separately, how significantly would performance be impacted? If there is a substantial performance difference, what factors contribute to it?”

for example

```auto
let userId = '4ec4f126-3f9d-11e7-84ef-b7c182b36521';

let objectIds: nkruntime.StorageReadRequest[] = [
  { collection: 'save', key: 'save1', userId: userId },
  { collection: 'save', key: 'save2', userId },
  { collection: 'save', key: 'save3', userId },
];

let results: nkruntime.StorageObject[] = [];

try {
    results = nk.storageRead(objectIds);
} catch (error) {
    

```

compare with

```auto
let userId = '4ec4f126-3f9d-11e7-84ef-b7c182b36521';

let objectId1: nkruntime.StorageReadRequest[] = [
  { collection: 'save', key: 'save1', userId: userId },
];

let objectId2: nkruntime.StorageReadRequest[] = [
  { collection: 'save', key: 'save2', userId },
];

let objectId3: nkruntime.StorageReadRequest[] = [
  { collection: 'save', key: 'save3', userId },
];

let results1: nkruntime.StorageObject[] = [];
let results2: nkruntime.StorageObject[] = [];
let results3: nkruntime.StorageObject[] = [];
try {
    results1 = nk.storageRead(objectIds1);
    results2 = nk.storageRead(objectIds2);
    results3 = nk.storageRead(objectIds3);
} catch (error) {
    

```

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [November 15, 2024, 10:28am UTC](https://forum.heroiclabs.com/t/nk-storageread-performance-compare/5806/2 "2024-11-15T10:28:50Z")

</div>

Hello @mengxin,

The difference is that each `nk.storageRead` performs a separate SQL query to the database, whilst all the reads in the same `nk.storageRead` are a single query.

Each separate call incurs in a round-trip to the database and another lookup. The performance impact depends on your DB hardware, load and other factors.

Essentially, it’s ok to split your reads across multiple calls if your logic so requires, but you should batch them within the same call whenever possible as it is more efficient.

Hope this clarifies.
