mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-01 03:52:15 +00:00
62 lines
1.8 KiB
Bash
Executable File
62 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
# shellcheck source=../shell_config.sh
|
|
. "$CURDIR"/../shell_config.sh
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS movement"
|
|
|
|
$CLICKHOUSE_CLIENT -n --query "CREATE TABLE movement (date DateTime('Europe/Moscow')) Engine = MergeTree ORDER BY (toStartOfHour(date));"
|
|
|
|
$CLICKHOUSE_CLIENT --query "insert into movement select toDateTime('2020-01-22 00:00:00', 'Europe/Moscow') + number%(23*3600) from numbers(1000000);"
|
|
|
|
$CLICKHOUSE_CLIENT --query "OPTIMIZE TABLE movement FINAL"
|
|
|
|
$CLICKHOUSE_CLIENT -n --query "
|
|
SELECT
|
|
count(),
|
|
toStartOfHour(date) AS Hour
|
|
FROM movement
|
|
WHERE (date >= toDateTime('2020-01-22T10:00:00', 'Europe/Moscow')) AND (date <= toDateTime('2020-01-22T23:00:00', 'Europe/Moscow'))
|
|
GROUP BY Hour
|
|
ORDER BY Hour DESC
|
|
" | grep "16:00:00" | cut -f1
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "alter table movement delete where date >= toDateTime('2020-01-22T16:00:00', 'Europe/Moscow') and date < toDateTime('2020-01-22T17:00:00', 'Europe/Moscow') SETTINGS mutations_sync = 2"
|
|
|
|
$CLICKHOUSE_CLIENT -n --query "
|
|
SELECT
|
|
count(),
|
|
toStartOfHour(date) AS Hour
|
|
FROM movement
|
|
WHERE (date >= toDateTime('2020-01-22T10:00:00', 'Europe/Moscow')) AND (date <= toDateTime('2020-01-22T23:00:00', 'Europe/Moscow'))
|
|
GROUP BY Hour
|
|
ORDER BY Hour DESC
|
|
" | grep "16:00:00" | wc -l
|
|
|
|
|
|
$CLICKHOUSE_CLIENT -n --query "
|
|
SELECT
|
|
count(),
|
|
toStartOfHour(date) AS Hour
|
|
FROM movement
|
|
WHERE (date >= toDateTime('2020-01-22T10:00:00', 'Europe/Moscow')) AND (date <= toDateTime('2020-01-22T23:00:00', 'Europe/Moscow'))
|
|
GROUP BY Hour
|
|
ORDER BY Hour DESC
|
|
" | grep "22:00:00" | cut -f1
|
|
|
|
|
|
$CLICKHOUSE_CLIENT -n --query "
|
|
SELECT
|
|
count(),
|
|
toStartOfHour(date) AS Hour
|
|
FROM movement
|
|
GROUP BY Hour
|
|
ORDER BY Hour DESC
|
|
" | grep "22:00:00" | cut -f1
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS movement"
|