1. Home
  2. Knowledge Base
  3. ClickHouse DBA
  4. Memory Limit Exceeded in ClickHouse
  1. Home
  2. Knowledge Base
  3. ClickHouse Performance
  4. Memory Limit Exceeded in ClickHouse

Memory Limit Exceeded in ClickHouse

Depending on the size of the SELECT or INSERT operation, we can see an error if memory usage is high.

Code: 241. DB::Exception: Received from localhost:9000. DB::Exception: Memory limit (for query) exceeded

Is there a method to workaround way? Of course, this method is purely for debugging purposes only.

SET max_memory_usage = (value)

This issue may be resolved by raising the max_memory_usage parameter limit as needed. However, this workaround is provided for implementation in non-prod environments.

Important Note: These solutions do not reduce memory usage. So, it is recommended for only non-prod environments.

For production environments, reordering the data will greatly reduce RAM use to permanently fix SELECT operation faults.

Was this article helpful?

Related Articles


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

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


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.