feat(ENodeConfigure):创建新超表的时候自动适配是否为分布式
This commit is contained in:
@@ -62,7 +62,13 @@ class ENodeConfigure {
|
||||
", $table_name
|
||||
));
|
||||
if (!in_array($table_name, pg_fetch_all_columns($table_exists, 1))) {
|
||||
$res[] = pg_query($this -> dbconn, sprintf("SELECT create_hypertable('\"%s\"', 'capture_time')", $table_name));
|
||||
$res[] = $node_count = pg_query($this -> dbconn, "SELECT COUNT(*) from timescaledb_information.data_nodes");
|
||||
if (intval(pg_fetch_assoc($node_count)['count']) === 0) {
|
||||
$res[] = pg_query($this -> dbconn, sprintf("SELECT create_hypertable('\"%s\"', 'capture_time')", $table_name));
|
||||
} else {
|
||||
$res[] = pg_query($this -> dbconn, sprintf("SELECT create_distributed_hypertable('\"%s\"', 'capture_time', 'code', 'device_code', 'parent_device_code', 'batch')", $table_name));
|
||||
}
|
||||
|
||||
$res[] = pg_query($this -> dbconn, sprintf(
|
||||
'CREATE INDEX ON "%s" (v_string, v_int, v_float, v_bool, capture_time DESC)
|
||||
WHERE COALESCE(v_string, v_int::text, v_float::text, v_bool::text) IS NOT NULL
|
||||
|
||||
Reference in New Issue
Block a user