Skip to main content
ClickHouse refuses to drop a MergeTree table or partition that is larger than a size limit, to protect you from deleting a lot of data by mistake. If you do want to drop it, pass the limit with the query: add SETTINGS max_table_size_to_drop = 0 to DROP TABLE, or SETTINGS max_partition_size_to_drop = 0 to ALTER TABLE ... DROP PARTITION. The value 0 removes the limit.

The error

The sizes in the message use decimal units, so the default limit is printed as 50.00 GB.

Which statements are checked

Both limits exist as a server setting (table, partition) and as a query-level setting with the same name (table, partition). When the query-level setting is changed (in the query, in the session, or in a settings profile), it is used instead of the server setting, whether it is larger or smaller. In ClickHouse Cloud the default is 1 TB, see max_table_size_to_drop.

Example

To reproduce the error without creating 50 GB of data, this example lowers both limits to 1 MB for the session:
The DROP TABLE fails with the error shown above. Check how large the partitions are:
Each partition is larger than max_partition_size_to_drop, so ALTER TABLE db.events DROP PARTITION 202601 fails with the same error, reporting Size (8.34 MB). With the limit passed in the query, the partition is dropped:

Ways to lift the limit

For one query or session

Add SETTINGS max_partition_size_to_drop = 0 or SETTINGS max_table_size_to_drop = 0 to the statement, or run SET before it. Instead of 0 you can pass a value in bytes that is larger than the table. This is the way to do it in ClickHouse Cloud. The table-level setting works the same way for TRUNCATE TABLE, DROP TABLE and DROP DATABASE:
The query-level settings are available since ClickHouse 23.12.

For the whole server

On a self-managed server, set the limits at the top level of the server configuration. The change is applied without a restart:

For one drop, with a flag file

On a self-managed server you can create the file named in the error message. ClickHouse deletes the file when it allows a drop, so the file permits exactly one statement and you have to create it again for the next one:
The directory is flags inside the ClickHouse data path, so use the path printed in your error message.

Without lifting the limit

If the table is larger than max_table_size_to_drop but every partition is smaller than max_partition_size_to_drop, you can drop the partitions one by one with ALTER TABLE ... DROP PARTITION and then drop the empty table. Use the query on system.parts above to list the partitions and their sizes.

Materialized views

A materialized view created without a TO clause stores its data in a hidden inner table, and dropping the view drops that table. If the inner table is larger than the limit, the error names the inner table:
Pass the setting when you drop the view:
The handling of the size limits for inner tables was fixed in ClickHouse 25.11. If the statement above still fails on an older release, first run DROP TABLE ... SETTINGS max_table_size_to_drop = 0 for the inner table, with the name copied from the error message and quoted with backticks, and then drop the view.