修正chunk size
This commit is contained in:
10
README.md
10
README.md
@@ -6,7 +6,7 @@
|
||||
- [0. HTTP POST: `set_node_data`](#0-http-post-set_node_data)
|
||||
- [开发环境](#开发环境)
|
||||
- [技术细节](#技术细节)
|
||||
- [0. `EdgeManager\EDataCapture\EDataCapture -> set_data()`为什么是以`6507524`为大小chunked的?](#0-edgemanageredatacaptureedatacapture---set_data为什么是以6507524为大小chunked的)
|
||||
- [0. `EdgeManager\EDataCapture\EDataCapture -> set_data()`为什么是以`6710885`为大小chunked的?](#0-edgemanageredatacaptureedatacapture---set_data为什么是以6710885为大小chunked的)
|
||||
|
||||
## API
|
||||
|
||||
@@ -124,7 +124,7 @@ psql -h localhost -U postgres
|
||||
|
||||
## 技术细节
|
||||
|
||||
### 0. `EdgeManager\EDataCapture\EDataCapture -> set_data()`为什么是以`6507524`为大小chunked的?
|
||||
### 0. `EdgeManager\EDataCapture\EDataCapture -> set_data()`为什么是以`6710885`为大小chunked的?
|
||||
|
||||
首先明确一点,根据PostgreSQL的技术架构,条件允许的情况下,**一次性插入多条记录是效率最高的**,比如:
|
||||
|
||||
@@ -152,12 +152,12 @@ PostgreSQL的文档里没有提及这个话题,因为源码里为SQL语句的
|
||||
|
||||
> 安全起见,下述计算假定working_subclass等字段的最大长度均为我们以往约定的45 bytes。
|
||||
|
||||
而此处我源码中的SQL语句头长度为131 bytes(注意末尾空格):
|
||||
而此处我源码中的SQL语句头长度为138 bytes(注意末尾空格):
|
||||
|
||||

|
||||
|
||||
单个语句体的长度为165 bytes:
|
||||
单个语句体的长度为160 bytes:
|
||||
|
||||

|
||||
|
||||
所以其最多可以一次性插入`(1073741823 - 131) / 165`条记录,向下取整后即为`6507524`。
|
||||
所以其最多可以一次性插入`(1073741823 - 138) / 160`条记录,向下取整后即为`6710885`。
|
||||
|
||||
@@ -11,7 +11,7 @@ class EDataCapture {
|
||||
) {}
|
||||
|
||||
function set_node_data() {
|
||||
foreach (array_chunk($this -> post -> param -> data, 6507524, true) as $chunk) {
|
||||
foreach (array_chunk($this -> post -> param -> data, 6710885, true) as $chunk) {
|
||||
$sql_head = sprintf(
|
||||
"INSERT INTO hf_mes_scada_data_capture_node_data_%s (code, v_%s, device_code, batch)
|
||||
VALUES",
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 9.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 12 KiB |
Reference in New Issue
Block a user