Skip to content

Instantly share code, notes, and snippets.

View filimonov's full-sized avatar

filimonov filimonov

View GitHub Profile
@filimonov
filimonov / matview_block_size.sql
Last active September 20, 2018 11:16
clickhouse matview vs max_block_size
CREATE TABLE mat_vew_src
(
id UInt64,
number UInt64
)
ENGINE = MergeTree
PARTITION BY tuple()
ORDER BY id
-- Ok.
@filimonov
filimonov / replug_vbox_network.cmd
Last active August 9, 2020 18:08
"Replug" the cable of running VirtualBox VM (network freeze in guest VM after host windows hybernate - awake)
@echo off
set VboxManageEXE="%VBOX_MSI_INSTALL_PATH%\VBoxManage.exe"
set ListRunningVMS=%VboxManageEXE% list runningvms
for /f tokens^=2^,4^ delims^=^" %%p in ('%ListRunningVMS%') do (
echo "%%p"
%VBoxManageEXE% controlvm %%p setlinkstate1 off
%VBoxManageEXE% controlvm %%p setlinkstate1 on
)
@filimonov
filimonov / gist:cd9c41f8eff1f0900312d90e51fbb081
Last active December 1, 2018 20:39
Allow creating symlinks in Windows 10 Home for users
1. Download https://gallery.technet.microsoft.com/scriptcenter/Grant-Revoke-Query-user-26e259b0#content
2. powershell as admin
3.
Import-Module .\UserRights.psm1
Grant-UserRight -Account "BUILTIN\Users" -Right SeCreateSymbolicLink
Get-AccountsWithUserRight -Right SeCreateSymbolicLink
Account Right SID
------- ----- ---
#!/usr/bin/env bash
for db_sql_full_filename in /var/lib/clickhouse/metadata/*.sql
do
dbfilename="${db_sql_full_filename##*/}";
dbname="${dbfilename%.sql}"
printf "\n/*************\n ** $dbname \n *************/\n"
perl -0777 -npe 's/^ATTACH/CREATE/; s/$/;\n/' $db_sql_full_filename;
printf "USE $dbname;\n\n"
@filimonov
filimonov / random_ascii_data.sql
Created January 2, 2019 09:37
fill table with random ascii data in ClickHouse
CREATE TABLE ascii_random_data ENGINE=TinyLog
AS
WITH
arrayStringConcat(
arrayMap(
x -> reinterpretAsString( toUInt8( rand(x) % 96 + 0x20 ) ),
range( 1024 )
)
) as str1024,
substring(str1024, 1, 512 + bitAnd(rand(),0x1FF) ) as str
@filimonov
filimonov / list_partitions.sql
Created January 11, 2019 13:17
Create queries to detach all the partitions in clickhouse
select 'ALTER TABLE '||database||'.'||table||' DETACH PARTITION '||partition||';' from system.parts group by database,table,partition ORDER BY database, table, partition FORMAT TSVRaw;
@filimonov
filimonov / check_different_presets.sh
Last active April 15, 2019 12:02
Lua script for formatting output of wrk to csv
URL='http://127.0.0.1:8123/ping'
EXTRA=''
echo 'query,extra,concurrency,threads,time_started,min_req,max_req,mean_req,req_stdev,min_latency,max_latency,mean_latency,latency_stdev,50th,75th,90th,99th,99.999th,duration,requests,bytes,connect_errors,read_errors,write_errors,status_errors,timeouts' > result.csv
for CONCURRENCY in 1 2 4 8 16 32 64 128 256 512 768 1024 1280 1536 1792 2048
do
if (( $CONCURRENCY < 8 )); then
THREADS=$CONCURRENCY
@filimonov
filimonov / max_insert_block_size_sample.md
Created May 24, 2019 12:32
max_insert_block_size effects when inserting via clickhouse-client

Default settings

create table xyz (number UInt64) Engine=MergeTree() ORDER BY number;

Inserting 100 mln numbers from CSV.

Each 'renaming' in log = one part created on the server.

@filimonov
filimonov / cluster.xml
Created August 5, 2019 12:28
test timeouts clickhouse issue #5317
<yandex>
<remote_servers>
<test_cluster>
<shard>
<internal_replication>false</internal_replication>
<replica>
<host>ch1</host>
<port>9000</port>
</replica>
<replica>
@filimonov
filimonov / keepalive.sh
Last active August 29, 2019 20:01 — forked from jcdang/keepalive.sh
clickhouse benchmark
#!/bin/bash
input="test.sql"
curl_config="/tmp/curl_config_file.txt"
echo > $curl_config
while IFS= read -r line
do
echo "next" >> $curl_config
echo "url=http://192.168.1.129:8123/?user=test&password=test&default_format=Null" >> $curl_config
echo "data=\"${line}\"" >> $curl_config