how to get the current value of a variable in the CLI?

1,045 views
Skip to first unread message

Kenji

unread,
Nov 24, 2020, 2:34:41 PM11/24/20
to ClickHouse
in the clickhouse-client I can set value like this:

SET max_threads = 4;

What's the opposite operation? How do I get the current value?  My question is not specific to max_threads.  It's just an example.


Nitesh Chaudhary

unread,
Nov 24, 2020, 2:41:17 PM11/24/20
to Kenji, ClickHouse
I don't remember the exact parameter name but this works:
You can get the current value by running the query  in system table:
select * from system.settings where name like '%thread%'
One of the parameters are gonna be max_thread which usually have auto value of the number of cores in your system.

--
You received this message because you are subscribed to the Google Groups "ClickHouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clickhouse+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clickhouse/53029829-01fd-4d41-9737-5d4e9f6be1d4n%40googlegroups.com.

Nitesh Chaudhary

unread,
Nov 24, 2020, 2:42:41 PM11/24/20
to Kenji, ClickHouse
++ Usually the user related parameters are +nt in system.settings table.

Kenji

unread,
Nov 24, 2020, 3:28:37 PM11/24/20
to ClickHouse
That worked great.
I confirmed the system.settings are per session e.g. SET max_threads=4 in a session doesn't affect another clickhouse-client session.
I also learned that "SET" is meant for settings only.  Therefore the name must exist in the system.settings.

Thank you.

Denis Zhuravlev

unread,
Nov 24, 2020, 3:47:29 PM11/24/20
to ClickHouse
There are custom settings as well. Starting from release v20.8.2.3-stable, 2020-09-08

SET custom_a = 123;
SELECT getSetting('custom_a');

Denis Zhuravlev

unread,
Nov 24, 2020, 3:58:20 PM11/24/20
to ClickHouse
SELECT getSetting('max_threads')

┌─getSetting('max_threads')─┐
│                         8 │
└───────────────────────────┘

Kenji

unread,
Nov 24, 2020, 7:01:51 PM11/24/20
to Denis Zhuravlev, ClickHouse
The getSetting function is neat.
Thanks for the custom settings, too. It will come in handy!
> To view this discussion on the web visit https://groups.google.com/d/msgid/clickhouse/d2dec45f-927d-43ef-88a5-681e06708399n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages