How to Set Credit Quota in Snowflake: Step-by-Step Guide
To set a credit quota in Snowflake, use the
ALTER WAREHOUSE command with the SET WAREHOUSE CREDIT QUOTA option. This limits the number of credits a warehouse can consume in a specified period, helping control costs.Syntax
The syntax to set a credit quota on a warehouse in Snowflake is:
ALTER WAREHOUSE <warehouse_name> SET WAREHOUSE CREDIT QUOTA = <number_of_credits>;
Here, <warehouse_name> is the name of your warehouse, and <number_of_credits> is the maximum credits allowed for the warehouse in a 7-day rolling period.
sql
ALTER WAREHOUSE my_warehouse SET WAREHOUSE CREDIT QUOTA = 100;
Example
This example sets a credit quota of 200 credits on a warehouse named analytics_wh. Once the warehouse consumes 200 credits in a 7-day rolling window, it will be suspended automatically to prevent further credit usage.
sql
ALTER WAREHOUSE analytics_wh SET WAREHOUSE CREDIT QUOTA = 200;
Output
Statement executed successfully.
Common Pitfalls
- Setting the credit quota too low may cause frequent warehouse suspensions, interrupting queries.
- Not setting a quota means unlimited credit usage, which can lead to unexpected costs.
- Credit quota applies per warehouse, so ensure you set quotas on all warehouses you want to control.
Example of a wrong approach (setting quota to zero):
ALTER WAREHOUSE analytics_wh SET WAREHOUSE CREDIT QUOTA = 0;
This disables the quota and allows unlimited credit usage. The correct way is to set a positive integer value.
sql
ALTER WAREHOUSE analytics_wh SET WAREHOUSE CREDIT QUOTA = 0; -- Wrong: disables quota ALTER WAREHOUSE analytics_wh SET WAREHOUSE CREDIT QUOTA = 150; -- Right: sets quota to 150 credits
Quick Reference
| Command | Description |
|---|---|
| ALTER WAREHOUSE | Sets the credit quota for the warehouse. |
| SHOW WAREHOUSES; | Lists warehouses and their credit quotas. |
| ALTER WAREHOUSE | Removes the credit quota limit. |
Key Takeaways
Use ALTER WAREHOUSE with SET WAREHOUSE CREDIT QUOTA to limit credit usage.
Credit quota is measured over a 7-day rolling period per warehouse.
Setting a quota prevents unexpected high costs by suspending warehouses after limit.
Avoid setting quota to zero as it disables the limit.
Check quotas regularly with SHOW WAREHOUSES to monitor usage.
