1.users.xml配置
注意:用戶和查詢級別設置在users.xml文件。
通過以下語句可以查詢及臨時設置:
localhost :) select * from system.settings where name='max_execution_time'; SELECT * FROM system.settings WHERE name = 'max_execution_time' Query id: 522b236f-6752-4590-8037-57be9f5a337a ┌─name───────────────┬─value─┬─changed─┬─description─┬─min──┬─max──┬─readonly─┬─type────┐ │ max_execution_time │ 0 │ 0 │ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ Seconds │ └────────────────────┴───────┴─────────┴─────────────┴──────┴──────┴──────────┴─────────┘ 1 rows in set. Elapsed: 0.003 sec. localhost :) localhost :) SET max_execution_time = 30; #臨時設置 SET max_execution_time = 30 Query id: 7f17aa03-4857-445e-8004-0df49e845f49 Ok. 0 rows in set. Elapsed: 0.001 sec. localhost :) localhost :) select * from system.settings where name='max_execution_time'; SELECT * FROM system.settings WHERE name = 'max_execution_time' Query id: e6fbda0b-e627-4ccc-b64f-c0d537c86def ┌─name───────────────┬─value─┬─changed─┬─description─┬─min──┬─max──┬─readonly─┬─type────┐ │ max_execution_time │ 30 │ 1 │ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ Seconds │ └────────────────────┴───────┴─────────┴─────────────┴──────┴──────┴──────────┴─────────┘ 1 rows in set. Elapsed: 0.002 sec. localhost :)
(1).max_memory_usage
用於在單個服務器上運行查詢的最大RAM量。在默認配置文件中,最大值為10GB。該設置不考慮計算機上的可用內存量或內存總量。該限制適用於單個服務器中的單個查詢。您可以使用 SHOW PROCESSLIST 查看每個查詢的當前內存消耗。此外,還會跟蹤每個查詢的內存消耗峰值並將其寫入日志。
不監視某些聚合函數的狀態的內存使用情況:
未完全跟蹤聚合函數的狀態的內存使用情況 min, max, any, anyLast, argMin, argMax 從 String 和 Array 。
內存消耗也受到參數的限制 max_memory_usage_for_user 和 max_memory_usage_for_all_queries.
(2).max_memory_usage_for_user
用於在單個服務器上運行用戶查詢的最大RAM量。默認情況下不受限制(max_memory_usage_for_user = 0)
(3).max_memory_usage_for_all_queries
用於在單個服務器上運行所有查詢的最大RAM數量。
(4).max_result_rows
限制結果中的行數。 還檢查子查詢,並在運行分布式查詢的部分時在遠程服務器上。
(5).max_execution_time
最大查詢執行時間(以秒為單位)。
此時,不會檢查其中一個排序階段,也不會在合並和最終確定聚合函數時進行檢查。
官方地址:https://clickhouse.tech/docs/zh/operations/settings/query-complexity/
2.修改users.xml文件使其永久生效
(1).修改max_execution_time(以秒為單位),此處設置為600秒
<max_execution_time>600</max_execution_time>
修改后,重啟clickhouse
systemctl restart clickhouse-server.service
然后查詢
localhost :) select * from system.settings where name='max_execution_time'; SELECT * FROM system.settings WHERE name = 'max_execution_time' Query id: 15886c4c-e7a0-40fc-8ec4-45021a222c84 ┌─name───────────────┬─value─┬─changed─┬─description─┬─min──┬─max──┬─readonly─┬─type────┐ │ max_execution_time │ 600 │ 1 │ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │ Seconds │ └────────────────────┴───────┴─────────┴─────────────┴──────┴──────┴──────────┴─────────┘ 1 rows in set. Elapsed: 0.003 sec. localhost :)
官方地址:https://clickhouse.tech/docs/zh/operations/settings/settings-profiles/
3.config.xml配置