From 21bbc8de91fde6ae54805f898055b1cb2697f6d2 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlov Date: Thu, 7 May 2026 15:39:05 +0300 Subject: [PATCH 1/4] IGNITE-28651 --- docs/_docs/SQL/sql-calcite.adoc | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/docs/_docs/SQL/sql-calcite.adoc b/docs/_docs/SQL/sql-calcite.adoc index 22c54986541b0..61942fbc1bf9b 100644 --- a/docs/_docs/SQL/sql-calcite.adoc +++ b/docs/_docs/SQL/sql-calcite.adoc @@ -121,6 +121,59 @@ QUERY_ENGINE=CALCITE ---- -- +== Memory Quotas [[memory-quotas]] + +The Calcite-based SQL engine can track and limit heap memory used by query execution. +This is useful for protecting a server node from a single large query or from many concurrent memory-heavy queries. + +Two quotas can be configured in `CalciteQueryEngineConfiguration`: + +* `globalMemoryQuota` - a per-node heap memory quota for all Calcite SQL queries running on the node. +* `queryMemoryQuota` - a per-node heap memory quota for each Calcite SQL query running on the node. + +Both quotas are disabled by default (`0`). +If a quota is exceeded, the query fails with an `IgniteSQLException`. +The global quota error message contains `Global memory quota for SQL queries exceeded`, and the per-query quota error message contains `Query quota exceeded`. + +The quota is applied to query execution structures that keep rows in heap memory, for example sorting, hash joins, hash aggregates, set operations, collection operations, spools, and result materialization. +It is not a process memory limit and it does not account for Ignite data regions, direct memory, JVM native memory, or the operating system page cache. +Size these quotas together with `-Xmx` and the expected SQL concurrency. + +[tabs] +-- +tab:XML[] +[source,xml] +---- + + + + + + + + + + + + + + + +---- +tab:Java[] +[source,java] +---- +IgniteConfiguration cfg = new IgniteConfiguration().setSqlConfiguration( + new SqlConfiguration().setQueryEnginesConfiguration( + new CalciteQueryEngineConfiguration() + .setDefault(true) + .setGlobalMemoryQuota(4L * 1024 * 1024 * 1024) + .setQueryMemoryQuota(512L * 1024 * 1024) + ) +); +---- +-- + == SQL Reference === DDL From ecb4dece3829772d7a1e8545937a5117a8bd42e6 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlov Date: Thu, 7 May 2026 15:51:52 +0300 Subject: [PATCH 2/4] IGNITE-28651 Document Calcite SQL memory quotas in Ignite 2.x documentation --- docs/_docs/SQL/sql-calcite.adoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/_docs/SQL/sql-calcite.adoc b/docs/_docs/SQL/sql-calcite.adoc index 61942fbc1bf9b..56895eb01e13b 100644 --- a/docs/_docs/SQL/sql-calcite.adoc +++ b/docs/_docs/SQL/sql-calcite.adoc @@ -123,7 +123,7 @@ QUERY_ENGINE=CALCITE == Memory Quotas [[memory-quotas]] -The Calcite-based SQL engine can track and limit heap memory used by query execution. +The Calcite-based SQL engine can track and limit heap memory accounted by Calcite query execution operators. This is useful for protecting a server node from a single large query or from many concurrent memory-heavy queries. Two quotas can be configured in `CalciteQueryEngineConfiguration`: @@ -132,11 +132,14 @@ Two quotas can be configured in `CalciteQueryEngineConfiguration`: * `queryMemoryQuota` - a per-node heap memory quota for each Calcite SQL query running on the node. Both quotas are disabled by default (`0`). +The quota values are specified in bytes. If a quota is exceeded, the query fails with an `IgniteSQLException`. The global quota error message contains `Global memory quota for SQL queries exceeded`, and the per-query quota error message contains `Query quota exceeded`. The quota is applied to query execution structures that keep rows in heap memory, for example sorting, hash joins, hash aggregates, set operations, collection operations, spools, and result materialization. It is not a process memory limit and it does not account for Ignite data regions, direct memory, JVM native memory, or the operating system page cache. +The quotas are per-node. +For a distributed query, total memory consumption across the cluster can be higher because the limit is applied independently on every participating node. Size these quotas together with `-Xmx` and the expected SQL concurrency. [tabs] From ca76855d3e6219da23a3ede6e28fed91213d9791 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlov Date: Thu, 7 May 2026 15:59:55 +0300 Subject: [PATCH 3/4] IGNITE-28651 local run fix, added required libs --- docs/Gemfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/Gemfile b/docs/Gemfile index 995be7b258772..c15a82fe07611 100644 --- a/docs/Gemfile +++ b/docs/Gemfile @@ -4,7 +4,7 @@ source "https://rubygems.org" gem 'asciidoctor' gem 'jekyll', group: :jekyll_plugins -gem 'wdm', '~> 0.1.1' if Gem.win_platform? +# gem 'wdm', '~> 0.1.1' if Gem.win_platform? group :jekyll_plugins do gem 'jekyll-asciidoc' gem 'jekyll-sass-converter', '~> 2.2' @@ -13,6 +13,10 @@ end gem 'thread_safe', '~> 0.3.6' gem 'slim', '~> 4.0.1' gem 'tilt', '~> 2.0.9' +gem 'bigdecimal', '~> 4.1' +gem 'base64', '~> 0.3' +gem 'csv', '~> 3.3' +gem 'logger', '~> 1.7' # Ruby 3.0.0 requires dependency which doesn't contains in the bundle gem "webrick", "~> 1.7" From 25f73fdccc4a66ec04224f52f99bc0ba291e895a Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlov Date: Thu, 7 May 2026 16:20:07 +0300 Subject: [PATCH 4/4] IGNITE-28651 review fixes --- docs/_docs/SQL/sql-calcite.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/_docs/SQL/sql-calcite.adoc b/docs/_docs/SQL/sql-calcite.adoc index 56895eb01e13b..722a3c7f7c03a 100644 --- a/docs/_docs/SQL/sql-calcite.adoc +++ b/docs/_docs/SQL/sql-calcite.adoc @@ -126,14 +126,14 @@ QUERY_ENGINE=CALCITE The Calcite-based SQL engine can track and limit heap memory accounted by Calcite query execution operators. This is useful for protecting a server node from a single large query or from many concurrent memory-heavy queries. -Two quotas can be configured in `CalciteQueryEngineConfiguration`: +Two types of quotas can be configured in `CalciteQueryEngineConfiguration`: * `globalMemoryQuota` - a per-node heap memory quota for all Calcite SQL queries running on the node. * `queryMemoryQuota` - a per-node heap memory quota for each Calcite SQL query running on the node. Both quotas are disabled by default (`0`). The quota values are specified in bytes. -If a quota is exceeded, the query fails with an `IgniteSQLException`. +If a quota is exceeded, the query fails with an exception. The global quota error message contains `Global memory quota for SQL queries exceeded`, and the per-query quota error message contains `Query quota exceeded`. The quota is applied to query execution structures that keep rows in heap memory, for example sorting, hash joins, hash aggregates, set operations, collection operations, spools, and result materialization.