1. Home
  2. Knowledge Base
  3. ChistaDATA
  4. ClickHouse Quotas – SQL reference
  1. Home
  2. Knowledge Base
  3. ClickHouse Cloud
  4. ClickHouse Quotas – SQL reference
  1. Home
  2. Knowledge Base
  3. ClickHouse DBA
  4. ClickHouse Quotas – SQL reference
  1. Home
  2. Knowledge Base
  3. RBAC
  4. ClickHouse Quotas – SQL reference

ClickHouse Quotas – SQL reference

Quotas are used to track and limit the resource usage for users/roles in ClickHouse. We can set the quotas inside the users.xml file or use SQL-driven workflow. Let us focus on the SQL-driven workflow in this article. We can restrict the following parameters in ClickHouse.

  • queries – Upper limit for the queries that can be executed by the user/role
  • query_selects – Upper limit for the SELECT queries that can be executed by the user/role
  • query_inserts – Upper limit for the INSERT queries that can be executed by the user/role
  • errors – Upper limit for the  queries for the user/role that can throw an exception/error
  • result_rows – Upper limit for the number of rows in the result set
  • read_rows – Upper limit for the rows that can be read for a query (including remote servers)
  • execution_time – Upper limit for the query execution time in seconds

Let us look at an example to create a quota to limit the number of queries that can be executed by a user called ‘test_user’ in a day. Ensure that you have access management privilege before we create the quotas.

CREATE QUOTA daily_limit FOR INTERVAL 1 DAY MAX QUERIES 100 TO test_user

The quota is named ‘daily_limit’ and the user can execute up to 100 queries.

To alter the quota, we can use ALTER statement.

ALTER QUOTA daily_limit FOR INTERVAL 2 DAY MAX QUERIES 50

The quota will now allow only 50 queries for a 2-day interval.

To delete the quota, we can use the DROP statement.

DROP QUOTA daily_limit;

 

References

https://clickhouse.com/docs/en/operations/quotas

https://kb.altinity.com/altinity-kb-setup-and-maintenance/rbac/

Was this article helpful?

Related Articles

CHISTADATA IS COMMITTED TO OPEN SOURCE SOFTWARE AND BUILDING HIGH PERFORMANCE COLUMNSTORES

In the spirit of freedom, independence and innovation. ChistaDATA Corporation is not affiliated with ClickHouse Corporation 

Contents

Need Support?

Can't find the answer you're looking for?
Contact Support

ChistaDATA Inc. Knowledge base is licensed under the Apache License, Version 2.0 (the “License”)

Copyright 2022 ChistaDATA Inc

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.