kintone レコード取得APIの fields 指定の効果

[kintone レコード取得APIのパラレル処理](http://qiita.com/rex0220/items/082190b972ad392f46ea) と同じ環境で、fields 指定の有無によるパフォーマンス検証を行ってみました。

約２万件をパラレル度５でレコード取得した場合、
光回線ではそれほど処理時間に差が出ないが、モバイル回線だと差が大きい結果となった。

| 回線 | fields 指定 |       処理時間 |
|------|----|------------:|
| 光回線   |  無し  |    15 秒|
| 光回線   |  有り  |    11 秒|
| モバイル回線   |  無し  |    44 秒|
| モバイル回線   |  有り  |    14 秒|

回線速度が遅いほど、fields 指定の効果がある。

# テスト条件

対象レコード 20,426 件

下記の組合せ

- パラレル度５で、fields 指定の有無　(4項目:29項目)
- 光回線およびモバイル回線でデザリング

# 項目

主に文字列と数値項目

![2017-03-16_20h14_04.png](https://qiita-image-store.s3.amazonaws.com/0/100572/525b03cb-2b88-3777-9eeb-a265bb9fa13a.png)



# ログ

## 光回線で fields 指定なし

約１５秒で完了。

```
SQL-CHECK start: 2017-03-16 20:16:24
api-get start: 2017-03-16 20:16:24
api-get-1 20:16:25 (1.482 秒) : fetch records,  500 rows.
api-p0 start: 2017-03-16 20:16:25
api-p1 start: 2017-03-16 20:16:25
api-p2 start: 2017-03-16 20:16:25
api-p3 start: 2017-03-16 20:16:25
api-p4 start: 2017-03-16 20:16:25
parray [Promise, Promise, Promise, Promise, Promise]
api-p3-1 20:16:27 (1.392 秒) : fetch records,  500 rows. offset 2000
api-p4-1 20:16:27 (1.473 秒) : fetch records,  500 rows. offset 2500
api-p1-1 20:16:27 (1.565 秒) : fetch records,  500 rows. offset 1000
api-p2-1 20:16:27 (1.662 秒) : fetch records,  500 rows. offset 1500
api-p0-1 20:16:27 (1.945 秒) : fetch records,  500 rows. offset 500
api-p3-2 20:16:28 (1.386 秒) : fetch records,  500 rows. offset 3000
api-p1-2 20:16:28 (1.416 秒) : fetch records,  500 rows. offset 4000
api-p4-2 20:16:28 (1.64 秒) : fetch records,  500 rows. offset 3500
api-p2-2 20:16:29 (1.676 秒) : fetch records,  500 rows. offset 4500
api-p0-2 20:16:29 (1.975 秒) : fetch records,  500 rows. offset 5000
api-p1-3 20:16:29 (1.26 秒) : fetch records,  500 rows. offset 6000
api-p3-3 20:16:30 (1.546 秒) : fetch records,  500 rows. offset 5500
api-p4-3 20:16:30 (1.542 秒) : fetch records,  500 rows. offset 6500
api-p2-3 20:16:30 (1.683 秒) : fetch records,  500 rows. offset 7000
api-p3-4 20:16:31 (1.293 秒) : fetch records,  500 rows. offset 8500
api-p1-4 20:16:31 (1.471 秒) : fetch records,  500 rows. offset 8000
api-p0-3 20:16:31 (1.929 秒) : fetch records,  500 rows. offset 7500
api-p4-4 20:16:31 (1.513 秒) : fetch records,  500 rows. offset 9000
api-p2-4 20:16:32 (1.44 秒) : fetch records,  500 rows. offset 9500
api-p1-5 20:16:32 (1.494 秒) : fetch records,  500 rows. offset 10500
api-p3-5 20:16:33 (1.678 秒) : fetch records,  500 rows. offset 10000
api-p0-4 20:16:33 (1.546 秒) : fetch records,  500 rows. offset 11000
api-p4-5 20:16:33 (1.552 秒) : fetch records,  500 rows. offset 11500
api-p2-5 20:16:33 (1.77 秒) : fetch records,  500 rows. offset 12000
api-p1-6 20:16:34 (1.354 秒) : fetch records,  500 rows. offset 12500
api-p3-6 20:16:34 (1.563 秒) : fetch records,  500 rows. offset 13000
api-p0-5 20:16:34 (1.75 秒) : fetch records,  500 rows. offset 13500
api-p4-6 20:16:34 (1.508 秒) : fetch records,  500 rows. offset 14000
api-p1-7 20:16:35 (1.46 秒) : fetch records,  500 rows. offset 15000
api-p2-6 20:16:35 (1.895 秒) : fetch records,  500 rows. offset 14500
api-p3-7 20:16:35 (1.397 秒) : fetch records,  500 rows. offset 15500
api-p0-6 20:16:36 (1.607 秒) : fetch records,  500 rows. offset 16000
api-p4-7 20:16:36 (1.605 秒) : fetch records,  500 rows. offset 16500
api-p2-7 20:16:37 (1.51 秒) : fetch records,  500 rows. offset 17500
api-p1-8 20:16:37 (1.713 秒) : fetch records,  500 rows. offset 17000
api-p3-8 20:16:37 (1.566 秒) : fetch records,  500 rows. offset 18000
api-p3 end ( 9 step ) : 2017-03-16 20:16:37 (11.821 秒)
api-p0-7 20:16:38 (1.525 秒) : fetch records,  500 rows. offset 18500
api-p0 end ( 8 step ) : 2017-03-16 20:16:38 (12.278 秒)
api-p4-8 20:16:38 (1.543 秒) : fetch records,  500 rows. offset 19000
api-p4 end ( 9 step ) : 2017-03-16 20:16:38 (12.377 秒)
api-p1-9 20:16:38 (1.214 秒) : fetch records,  426 rows. offset 20000
api-p1 end ( 10 step ) : 2017-03-16 20:16:38 (12.948 秒)
api-p2-8 20:16:39 (1.687 秒) : fetch records,  500 rows. offset 19500
api-p2 end ( 9 step ) : 2017-03-16 20:16:39 (13.323 秒)
Promise.all [true, true, true, true, true]
api-get end ( 2 step ) : 2017-03-16 20:16:39 (14.827 秒)
SQL-CHECK-1 20:16:39 (14.83 秒) : get record,  20426 records.
SQL-CHECK-2 20:16:39 (0.413 秒) : convert rows,  20426 rows.
SQL-CHECK-3 20:16:39 (0.067 秒) : select group by,  3 rows.
SQL-CHECK-4 20:16:39 (0.053 秒) : grid display 
SQL-CHECK end ( 5 step ) : 2017-03-16 20:16:39 (15.364 秒)
```

回線速度が早いと転送時間はそれほど増えない。

![2017-03-16_20h18_16.png](https://qiita-image-store.s3.amazonaws.com/0/100572/8ac18e5a-3d86-2d8f-92c1-4711099718c8.png)


## 光回線で fields 指定あり

約１１秒で完了。

```
SQL-CHECK start: 2017-03-16 15:50:04
api-get start: 2017-03-16 15:50:04
api-get-1 15:50:05 (1.106 秒) : fetch records,  500 rows.
api-p0 start: 2017-03-16 15:50:05
api-p1 start: 2017-03-16 15:50:05
api-p2 start: 2017-03-16 15:50:05
api-p3 start: 2017-03-16 15:50:05
api-p4 start: 2017-03-16 15:50:05
 parray [Promise, Promise, Promise, Promise, Promise]
api-p2-1 15:50:06 (1.109 秒) : fetch records,  500 rows. offset 1500
api-p1-1 15:50:06 (1.126 秒) : fetch records,  500 rows. offset 1000
api-p4-1 15:50:06 (1.136 秒) : fetch records,  500 rows. offset 2500
api-p0-1 15:50:06 (1.227 秒) : fetch records,  500 rows. offset 500
api-p3-1 15:50:06 (1.251 秒) : fetch records,  500 rows. offset 2000
api-p2-2 15:50:07 (1.126 秒) : fetch records,  500 rows. offset 3000
api-p4-2 15:50:08 (1.184 秒) : fetch records,  500 rows. offset 4000
api-p1-2 15:50:08 (1.218 秒) : fetch records,  500 rows. offset 3500
api-p3-2 15:50:08 (1.2 秒) : fetch records,  500 rows. offset 5000
api-p0-2 15:50:08 (1.247 秒) : fetch records,  500 rows. offset 4500
api-p2-3 15:50:09 (1.136 秒) : fetch records,  500 rows. offset 5500
api-p3-3 15:50:09 (0.97 秒) : fetch records,  500 rows. offset 7000
api-p4-3 15:50:09 (1.165 秒) : fetch records,  500 rows. offset 6000
api-p1-3 15:50:09 (1.232 秒) : fetch records,  500 rows. offset 6500
api-p0-3 15:50:09 (1.259 秒) : fetch records,  500 rows. offset 7500
api-p2-4 15:50:10 (1.219 秒) : fetch records,  500 rows. offset 8000
api-p3-4 15:50:10 (1.183 秒) : fetch records,  500 rows. offset 8500
api-p4-4 15:50:10 (1.157 秒) : fetch records,  500 rows. offset 9000
api-p1-4 15:50:10 (1.156 秒) : fetch records,  500 rows. offset 9500
api-p0-4 15:50:10 (1.17 秒) : fetch records,  500 rows. offset 10000
api-p2-5 15:50:11 (1.168 秒) : fetch records,  500 rows. offset 10500
api-p3-5 15:50:11 (1.224 秒) : fetch records,  500 rows. offset 11000
api-p1-5 15:50:11 (1.214 秒) : fetch records,  500 rows. offset 12000
api-p4-5 15:50:11 (1.351 秒) : fetch records,  500 rows. offset 11500
api-p0-5 15:50:11 (1.193 秒) : fetch records,  500 rows. offset 12500
api-p2-6 15:50:12 (1.177 秒) : fetch records,  500 rows. offset 13000
api-p3-6 15:50:12 (1.117 秒) : fetch records,  500 rows. offset 13500
api-p1-6 15:50:12 (1.163 秒) : fetch records,  500 rows. offset 14000
api-p4-6 15:50:12 (1.127 秒) : fetch records,  500 rows. offset 14500
api-p0-6 15:50:12 (1.146 秒) : fetch records,  500 rows. offset 15000
api-p3-7 15:50:13 (1.052 秒) : fetch records,  500 rows. offset 16000
api-p2-7 15:50:13 (1.273 秒) : fetch records,  500 rows. offset 15500
api-p4-7 15:50:14 (1.236 秒) : fetch records,  500 rows. offset 17000
api-p1-7 15:50:14 (1.28 秒) : fetch records,  500 rows. offset 16500
api-p0-7 15:50:14 (1.237 秒) : fetch records,  500 rows. offset 17500
api-p3-8 15:50:14 (1.163 秒) : fetch records,  500 rows. offset 18000
api-p3 end ( 9 step ) : 2017-03-16 15:50:14 (9.161 秒)
api-p2-8 15:50:15 (1.135 秒) : fetch records,  500 rows. offset 18500
api-p2 end ( 9 step ) : 2017-03-16 15:50:15 (9.344 秒)
api-p0-8 15:50:15 (0.92 秒) : fetch records,  426 rows. offset 20000
api-p0 end ( 9 step ) : 2017-03-16 15:50:15 (9.399 秒)
api-p1-8 15:50:15 (1.206 秒) : fetch records,  500 rows. offset 19500
api-p1 end ( 9 step ) : 2017-03-16 15:50:15 (9.596 秒)
api-p4-8 15:50:15 (1.269 秒) : fetch records,  500 rows. offset 19000
api-p4 end ( 9 step ) : 2017-03-16 15:50:15 (9.625 秒)
 Promise.all [true, true, true, true, true]
api-get end ( 2 step ) : 2017-03-16 15:50:15 (10.753 秒)
SQL-CHECK-1 15:50:15 (10.759 秒) : get record,  20426 records.
SQL-CHECK-2 15:50:15 (0.06 秒) : convert rows,  20426 rows.
SQL-CHECK-3 15:50:15 (0.069 秒) : select group by,  3 rows.
SQL-CHECK-4 15:50:15 (0.056 秒) : grid display 
SQL-CHECK end ( 5 step ) : 2017-03-16 15:50:15 (10.945 秒)
```


## モバイル回線で fields 指定なし

API １回の処理時間が３秒から６秒になっている。

```
SQL-CHECK start: 2017-03-16 19:37:40
api-get start: 2017-03-16 19:37:41
api-get-1 19:37:44 (3.365 秒) : fetch records,  500 rows.
api-p0 start: 2017-03-16 19:37:44
api-p1 start: 2017-03-16 19:37:44
api-p2 start: 2017-03-16 19:37:44
api-p3 start: 2017-03-16 19:37:44
api-p4 start: 2017-03-16 19:37:44
parray [Promise, Promise, Promise, Promise, Promise]
api-p0-1 19:37:47 (2.941 秒) : fetch records,  500 rows. offset 500
api-p2-1 19:37:48 (3.801 秒) : fetch records,  500 rows. offset 1500
api-p4-1 19:37:48 (4.15 秒) : fetch records,  500 rows. offset 2500
api-p3-1 19:37:48 (4.308 秒) : fetch records,  500 rows. offset 2000
api-p1-1 19:37:50 (6.046 秒) : fetch records,  500 rows. offset 1000
api-p4-2 19:37:51 (3.022 秒) : fetch records,  500 rows. offset 4000
api-p2-2 19:37:51 (3.527 秒) : fetch records,  500 rows. offset 3500
api-p0-2 19:37:52 (4.693 秒) : fetch records,  500 rows. offset 3000
api-p3-2 19:37:53 (5.061 秒) : fetch records,  500 rows. offset 4500
api-p1-2 19:37:54 (3.939 秒) : fetch records,  500 rows. offset 5000
api-p2-3 19:37:55 (3.713 秒) : fetch records,  500 rows. offset 6000
api-p0-3 19:37:55 (3.835 秒) : fetch records,  500 rows. offset 6500
api-p4-3 19:37:56 (4.503 秒) : fetch records,  500 rows. offset 5500
api-p3-3 19:37:57 (3.89 秒) : fetch records,  500 rows. offset 7000
api-p1-3 19:37:58 (4.095 秒) : fetch records,  500 rows. offset 7500
api-p2-4 19:37:59 (3.834 秒) : fetch records,  500 rows. offset 8000
api-p0-4 19:37:59 (3.601 秒) : fetch records,  500 rows. offset 8500
api-p4-4 19:38:01 (5.15 秒) : fetch records,  500 rows. offset 9000
api-p3-4 19:38:01 (3.808 秒) : fetch records,  500 rows. offset 9500
api-p2-5 19:38:02 (3.333 秒) : fetch records,  500 rows. offset 10500
api-p1-4 19:38:03 (4.967 秒) : fetch records,  500 rows. offset 10000
api-p4-5 19:38:05 (3.817 秒) : fetch records,  500 rows. offset 11500
api-p3-5 19:38:05 (3.696 秒) : fetch records,  500 rows. offset 12000
api-p0-5 19:38:05 (6.011 秒) : fetch records,  500 rows. offset 11000
api-p2-6 19:38:07 (5.301 秒) : fetch records,  500 rows. offset 12500
api-p3-6 19:38:08 (3.855 秒) : fetch records,  500 rows. offset 14000
api-p1-5 19:38:10 (7.047 秒) : fetch records,  500 rows. offset 13000
api-p0-6 19:38:11 (5.908 秒) : fetch records,  500 rows. offset 14500
api-p4-6 19:38:12 (7.658 秒) : fetch records,  500 rows. offset 13500
api-p3-7 19:38:13 (4.672 秒) : fetch records,  500 rows. offset 15500
api-p2-7 19:38:14 (6.53 秒) : fetch records,  500 rows. offset 15000
api-p1-6 19:38:15 (4.892 秒) : fetch records,  500 rows. offset 16000
api-p4-7 19:38:16 (4.258 秒) : fetch records,  500 rows. offset 17000
api-p0-7 19:38:17 (5.724 秒) : fetch records,  500 rows. offset 16500
api-p2-8 19:38:18 (4.252 秒) : fetch records,  500 rows. offset 18000
api-p3-8 19:38:19 (5.754 秒) : fetch records,  500 rows. offset 17500
api-p3 end ( 9 step ) : 2017-03-16 19:38:19 (35.045 秒)
api-p4-8 19:38:20 (3.429 秒) : fetch records,  500 rows. offset 19000
api-p4 end ( 9 step ) : 2017-03-16 19:38:20 (35.988 秒)
api-p0-8 19:38:20 (3.696 秒) : fetch records,  500 rows. offset 19500
api-p0 end ( 9 step ) : 2017-03-16 19:38:20 (36.409 秒)
api-p1-7 19:38:21 (6.201 秒) : fetch records,  500 rows. offset 18500
api-p1 end ( 8 step ) : 2017-03-16 19:38:21 (37.188 秒)
api-p2-9 19:38:24 (5.625 秒) : fetch records,  426 rows. offset 20000
api-p2 end ( 10 step ) : 2017-03-16 19:38:24 (39.916 秒)
Promise.all [true, true, true, true, true]
api-get end ( 2 step ) : 2017-03-16 19:38:24 (43.292 秒)
SQL-CHECK-1 19:38:24 (43.297 秒) : get record,  20426 records.
SQL-CHECK-2 19:38:24 (0.452 秒) : convert rows,  20426 rows.
SQL-CHECK-3 19:38:24 (0.081 秒) : select group by,  3 rows.
SQL-CHECK-4 19:38:24 (0.049 秒) : grid display 
SQL-CHECK end ( 5 step ) : 2017-03-16 19:38:24 (43.879 秒)
```

回線速度が遅いと、転送時間に１秒以上かかかる。

![2017-03-16_19h40_06.png](https://qiita-image-store.s3.amazonaws.com/0/100572/8bf3c753-fd44-22cd-6eae-1e889a31abf5.png)


## モバイル回線で fields 指定あり

API １回の処理時間が２秒以内になっている。


```
SQL-CHECK start: 2017-03-16 19:41:32
api-get start: 2017-03-16 19:41:32
api-get-1 19:41:33 (1.544 秒) : fetch records,  500 rows.
api-p0 start: 2017-03-16 19:41:33
api-p1 start: 2017-03-16 19:41:33
api-p2 start: 2017-03-16 19:41:33
api-p3 start: 2017-03-16 19:41:33
api-p4 start: 2017-03-16 19:41:33
parray [Promise, Promise, Promise, Promise, Promise]
api-p3-1 19:41:35 (1.32 秒) : fetch records,  500 rows. offset 2000
api-p0-1 19:41:35 (1.362 秒) : fetch records,  500 rows. offset 500
api-p2-1 19:41:35 (1.492 秒) : fetch records,  500 rows. offset 1500
api-p1-1 19:41:35 (1.507 秒) : fetch records,  500 rows. offset 1000
api-p4-1 19:41:35 (1.81 秒) : fetch records,  500 rows. offset 2500
api-p3-2 19:41:36 (1.303 秒) : fetch records,  500 rows. offset 3000
api-p0-2 19:41:36 (1.402 秒) : fetch records,  500 rows. offset 3500
api-p1-2 19:41:36 (1.268 秒) : fetch records,  500 rows. offset 4500
api-p2-2 19:41:36 (1.309 秒) : fetch records,  500 rows. offset 4000
api-p4-2 19:41:37 (1.446 秒) : fetch records,  500 rows. offset 5000
api-p2-3 19:41:37 (1.365 秒) : fetch records,  500 rows. offset 7000
api-p1-3 19:41:37 (1.409 秒) : fetch records,  500 rows. offset 6500
api-p0-3 19:41:38 (1.453 秒) : fetch records,  500 rows. offset 6000
api-p4-3 19:41:38 (1.497 秒) : fetch records,  500 rows. offset 7500
api-p3-3 19:41:38 (2.516 秒) : fetch records,  500 rows. offset 5500
api-p0-4 19:41:39 (1.237 秒) : fetch records,  500 rows. offset 9000
api-p1-4 19:41:39 (1.464 秒) : fetch records,  500 rows. offset 8500
api-p2-4 19:41:39 (1.541 秒) : fetch records,  500 rows. offset 8000
api-p4-4 19:41:40 (1.59 秒) : fetch records,  500 rows. offset 9500
api-p3-4 19:41:40 (1.588 秒) : fetch records,  500 rows. offset 10000
api-p0-5 19:41:40 (1.521 秒) : fetch records,  500 rows. offset 10500
api-p1-5 19:41:40 (1.361 秒) : fetch records,  500 rows. offset 11000
api-p2-5 19:41:40 (1.449 秒) : fetch records,  500 rows. offset 11500
api-p4-5 19:41:41 (1.402 秒) : fetch records,  500 rows. offset 12000
api-p3-5 19:41:42 (1.556 秒) : fetch records,  500 rows. offset 12500
api-p0-6 19:41:42 (1.575 秒) : fetch records,  500 rows. offset 13000
api-p1-6 19:41:42 (1.551 秒) : fetch records,  500 rows. offset 13500
api-p2-6 19:41:42 (1.444 秒) : fetch records,  500 rows. offset 14000
api-p4-6 19:41:43 (1.546 秒) : fetch records,  500 rows. offset 14500
api-p3-6 19:41:43 (1.523 秒) : fetch records,  500 rows. offset 15000
api-p2-7 19:41:43 (1.469 秒) : fetch records,  500 rows. offset 16500
api-p1-7 19:41:43 (1.545 秒) : fetch records,  500 rows. offset 16000
api-p0-7 19:41:43 (1.573 秒) : fetch records,  500 rows. offset 15500
api-p4-7 19:41:44 (1.506 秒) : fetch records,  500 rows. offset 17000
api-p3-7 19:41:45 (1.401 秒) : fetch records,  500 rows. offset 17500
api-p0-8 19:41:45 (1.419 秒) : fetch records,  500 rows. offset 19000
api-p0 end ( 9 step ) : 2017-03-16 19:41:45 (11.543 秒)
api-p2-8 19:41:45 (1.593 秒) : fetch records,  500 rows. offset 18000
api-p2 end ( 9 step ) : 2017-03-16 19:41:45 (11.663 秒)
api-p1-8 19:41:45 (1.651 秒) : fetch records,  500 rows. offset 18500
api-p1 end ( 9 step ) : 2017-03-16 19:41:45 (11.757 秒)
api-p4-8 19:41:46 (1.491 秒) : fetch records,  500 rows. offset 19500
api-p4 end ( 9 step ) : 2017-03-16 19:41:46 (12.289 秒)
api-p3-8 19:41:46 (1.293 秒) : fetch records,  426 rows. offset 20000
api-p3 end ( 9 step ) : 2017-03-16 19:41:46 (12.5 秒)
Promise.all [true, true, true, true, true]
api-get end ( 2 step ) : 2017-03-16 19:41:46 (14.058 秒)
SQL-CHECK-1 19:41:46 (14.062 秒) : get record,  20426 records.
SQL-CHECK-2 19:41:46 (0.059 秒) : convert rows,  20426 rows.
SQL-CHECK-3 19:41:46 (0.065 秒) : select group by,  3 rows.
SQL-CHECK-4 19:41:46 (0.04 秒) : grid display 
SQL-CHECK end ( 5 step ) : 2017-03-16 19:41:46 (14.226 秒)
```

fields 指定により、データ量が削減され、転送時間が 1.32 ms と、ほとんどかかっていない。

![2017-03-16_19h42_40.png](https://qiita-image-store.s3.amazonaws.com/0/100572/f9393082-4b63-2209-155d-9239e76d6bf2.png)