Commit 1e32443a authored by HTH's avatar HTH

更新

parent 99368440
...@@ -15,5 +15,40 @@ ...@@ -15,5 +15,40 @@
<jdbc-url>jdbc:clickhouse://39.108.185.243:18123</jdbc-url> <jdbc-url>jdbc:clickhouse://39.108.185.243:18123</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir> <working-dir>$ProjectFileDir$</working-dir>
</data-source> </data-source>
<data-source source="LOCAL" name="运维生产环境" uuid="73b0f6e4-be42-4655-a2a7-187c8c532525">
<driver-ref>clickhouse</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>ru.yandex.clickhouse.ClickHouseDriver</jdbc-driver>
<jdbc-url>jdbc:clickhouse://119.23.65.157:8123</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="新科云测试环境" uuid="7490c087-270d-4818-9630-37815b4f31f7">
<driver-ref>clickhouse</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>ru.yandex.clickhouse.ClickHouseDriver</jdbc-driver>
<jdbc-url>jdbc:clickhouse://120.79.30.193:8123</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="新科云生产环境" uuid="010638e2-3e89-43df-a557-f1dffa19eb12">
<driver-ref>clickhouse</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>ru.yandex.clickhouse.ClickHouseDriver</jdbc-driver>
<jdbc-url>jdbc:clickhouse://106.55.236.122:8123</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="中车驾驶舱预发布环境" uuid="4679a17f-92f7-4c85-9e2c-35918b01d95a">
<driver-ref>clickhouse</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>ru.yandex.clickhouse.ClickHouseDriver</jdbc-driver>
<jdbc-url>jdbc:clickhouse://39.108.210.27:8123</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="test-taos" uuid="b6f9f0b4-a47e-40af-9a46-478f661ebd70">
<synchronize>true</synchronize>
<configured-by-url>true</configured-by-url>
<jdbc-driver>com.taosdata.jdbc.rs.RestfulDriver</jdbc-driver>
<jdbc-url>jdbc:TAOS-RS://120.79.155.65:6041/thinker_cloud_device_service</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component> </component>
</project> </project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/按分区查询及删除数据.sql" dialect="ClickHouse" />
<file url="file://$PROJECT_DIR$/按分区查询及删除系统表数据.sql" dialect="ClickHouse" />
<file url="file://$PROJECT_DIR$/统计磁盘.sql" dialect="ClickHouse" />
<file url="file://$PROJECT_DIR$/../fox/ddl.sql" dialect="ClickHouse" />
<file url="file://$PROJECT_DIR$/../fox/pgToClickhouse.sql" dialect="ClickHouse" />
<file url="file://$PROJECT_DIR$/../fox/查询轮询数据.sql" dialect="ClickHouse" />
</component>
</project>
\ No newline at end of file
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
<module type="DBE_MODULE" version="4"> <module type="DBE_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<content url="file://$MODULE_DIR$/../fox" />
<content url="file://$MODULE_DIR$/../taosSql" />
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
show processlist;
select user, query_id, query, elapsed, memory_usage
from system. processes;
KILL QUERY WHERE user='thinker'
select query_id, read_rows, total_rows_approx, memory_usage, initial_user, initial_address, elapsed
, query
from system. processes _all order by read_rows desc;
-- 37366
SELECT
count(1)
FROM system.mutations
where is_done = 0;
SELECT
mutation_id,
database,
table,
command,
create_time,
is_done
FROM system.mutations
where is_done = 0
LIMIT 1000
KILL MUTATION WHERE mutation_id = 'mutation_19567702.txt';
KILL MUTATION where database = 'thinker_cloud_device_service';
KILL MUTATION WHERE mutation_id in (SELECT
mutation_id,
database,
table,
command,
create_time,
is_done
FROM system.mutations
where is_done = 0
limit 1);
\ No newline at end of file
select base.*
from meter_data as base
where timestamp >='2022-10-14 16:00:00' and timestamp <='2022-10-14 16:59:59'
and base.meter_attr_id in(32546,31859)
order by timestamp desc
limit 1
with
temp as (
select base.*
from meter_data as base
where timestamp >='2022-10-14 16:00:00' and timestamp <='2022-10-14 17:59:59'
and base.meter_attr_id in(32546,31859)
)
select temp.*
from temp
where id in(
select min(temp.id) from temp group by meter_attr_id
)
-- 所有站用电量之和
select sum(toDecimal256(value, 4) )
from meter_data
where timestamp >='2022-10-16 20:00:00' and timestamp <='2022-10-16 20:59:59'
and meter_attr_id in (
38548
,36892
,36894
,36899
,38550
,38552
);
-- 所有站用气量之和
select sum(toDecimal256(value, 4) )
from meter_data
where timestamp >='2022-10-16 19:00:00' and timestamp <='2022-10-16 19:59:59'
and meter_attr_id in (
38547
,36893
,36895
,36898
,38549
,38551
);
...@@ -26,4 +26,74 @@ from meter_data ...@@ -26,4 +26,74 @@ from meter_data
group by toDate(time); group by toDate(time);
select version(), timezone(); alter table device_polling
\ No newline at end of file update content='test'
where timestamp='2022-02-24 10:22:13.510000';
alter table meter_data
update dirty=1
where timestamp='2022-02-24 16:30:22.772069';
select version(), timezone(), now();
select *
from meter_data
where timestamp>='2022-02-23 00:00:00.000'
and timestamp<='2022-03-01 23:59:59.999'
and meter_attr_id=15701
order by timestamp desc
limit 10 offset 0;
select count(*)
from meter_data
where timestamp>='2022-02-23 00:00:00.000'
and timestamp<='2022-03-01 23:59:59.999'
and meter_attr_id=15701;
ALTER TABLE meter_data DROP PARTITION '20220228'
select *
from meter_data_storage_extend base
where base.timestamp >= '2022-03-01 07:00:03' and base.timestamp < '2022-03-02 07:00:03'
and has(splitByString(',', functions), 'max')
limit 10 offset 0;
select count(*)
from meter_data
where timestamp>='2022-03-03 00:00:00.000'
and timestamp<='2022-03-09 23:59:59.999'
and meter_attr_id=30586;
select meter_attr_id
, date_trunc('hour', "timestamp") AS dataTime
, any(value) as first
, anyLast(value) as last
, max(toDecimal128(value, 6)) as max
, min(toDecimal128(value, 6)) as min
, avg(toDecimal128(value, 6)) as avg
, sum(toDecimal128(value, 6)) as sum
, count(1) as count
from meter_data
where dirty = 0
and "timestamp" >= '2022-03-10 08:00:00'
AND "timestamp" < '2022-03-10 09:00:00'
GROUP BY meter_attr_id, dataTime
ORDER BY avg desc;
ALTER TABLE system.part_log MODIFY TTL event_date + toIntervalDay(10);
select version()
-- 修改数据
alter table meter_data update value=145
where meter_attr_id=36892 and timestamp='2022-09-08 08:59:59.000000'
alter table meter_data delete where timestamp='2022-09-08 05:59:59.000000' and meter_attr_id= 36892;
\ No newline at end of file
select partition,table from system.parts p where table = 'part_log'
group by partition,table
order by partition;
ALTER TABLE system.part_log DROP PARTITION '202203';
select table
from system.parts p
where active
order by data_compressed_bytes desc;
alter table system.query_log delete where query_log.event_date<'2022-04-10';
truncate table system.trace_log;
select *
from system.part_log;
alter table system.part_log delete where event_date>='2022-05-01' and event_date<'2022-06-30'
alter table reporting_raw_data drop partition ('2022-03-09','2022-08-20');
alter table reporting_raw_data drop partition '2022-03-09';
alter table system.part_log drop partition '202203';
-- 查询
select partition,table from system.parts p where table = 'part_log'
group by partition,table
order by partition;
select *
from system.part_log
order by event_date;
select table
from system.parts p
where active
order by data_compressed_bytes desc;
-- 删除数据
truncate table system.part_log;
truncate table system.trace_log;
ALTER TABLE part_log DROP PARTITION '202205';
alter table system.part_log delete where event_date>='2022-05-01' and event_date<'2022-06-30';
alter table system.query_log delete where event_date<'2022-06-30';
alter table system.query_thread_log delete where event_date<'2022-06-30';
ALTER TABLE system.part_log MODIFY TTL event_date + toIntervalDay(2);
truncate table system.session_log;
select version();
...@@ -27,11 +27,13 @@ from ...@@ -27,11 +27,13 @@ from
size / (max_date - min_date) as avgDaySize size / (max_date - min_date) as avgDaySize
from system.parts from system.parts
where active where active
and database = 'hth' and database = 'system'
and table = 'meter_data' -- and database = 'thinker_cloud_device_service'
-- and table = 'meter_data'
group by group by
database, database,
table table
order by size desc
); );
-- 数据库容量统计 -- 数据库容量统计
select select
...@@ -39,7 +41,32 @@ select ...@@ -39,7 +41,32 @@ select
formatReadableSize(sum(data_uncompressed_bytes)) as ysq,--原始大小 formatReadableSize(sum(data_uncompressed_bytes)) as ysq,--原始大小
formatReadableSize(sum(data_compressed_bytes)) as ysh,--压缩大小 formatReadableSize(sum(data_compressed_bytes)) as ysh,--压缩大小
round(sum(data_compressed_bytes) / sum(data_uncompressed_bytes) * 100, 0) ys_rate--压缩率 round(sum(data_compressed_bytes) / sum(data_uncompressed_bytes) * 100, 0) ys_rate--压缩率
from system.parts; from system.parts
where active
and database = 'fox_device_service';
-- 查看分区
select *
from system.parts
where active and table='meter_data';
SELECT query_id,user, query FROM system.processes;
select * from system.metrics where metric like '%Connection'
select
toStartOfInterval(base.timestamp, INTERVAL 1 hour) as xValueDateTime,
-- date_trunc('hour', base.timestamp) as xValueDateTime,
toDecimal128(max(toDecimal128(base.value, 4)), 4) as yValue
from meter_data as base
where timestamp>='2022-05-13 00:00:00' and timestamp<='2022-05-14 00:00:00'
GROUP BY xValueDateTime
order by xValueDateTime;
ALTER TABLE system.parts MODIFY TTL event_date + toIntervalDay(10);
select version()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment