Skip to content

Reserve memory for one partition at a time - #2035

Draft
Alena0704 wants to merge 1 commit into
apache:REL_2_STABLEfrom
Alena0704:fix-memquota-append-rel2
Draft

Alena0704 wants to merge 1 commit into
apache:REL_2_STABLEfrom
Alena0704:fix-memquota-append-rel2

Conversation

@Alena0704

@Alena0704 Alena0704 commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

Partitions are scanned one after another, but the memory check counted all of them at once, 100kB each. So a table with 200 partitions needed 20MB just to start a query, and with less the query failed:

create table p (id int, d date) distributed by (id)
partition by range (d)
(start ('2020-01-01'::date) end ('2020-07-19'::date)
every ('1 day'::interval));

set optimizer = off; -- ORCA scans all partitions with one node
set statement_mem = '2MB';
select count(*) from p;

ERROR: insufficient memory reserved for statement

Count only the largest partition instead of all of them.

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


@Alena0704 Alena0704 added the type: Bug Something isn't working label Sep 19, 2026
Partitions are scanned one after another, but the memory check counted
all of them at once, 100kB each.  So a table with 200 partitions needed
20MB just to start a query, and with less the query failed:

  create table p (id int, d date) distributed by (id)
    partition by range (d)
    (start ('2020-01-01'::date) end ('2020-07-19'::date)
     every ('1 day'::interval));

  set optimizer = off;   -- ORCA scans all partitions with one node
  set statement_mem = '2MB';
  select count(*) from p;

  ERROR:  insufficient memory reserved for statement

Count only the largest partition instead of all of them.
@Alena0704
Alena0704 force-pushed the fix-memquota-append-rel2 branch from cc71709 to 9a6bfab Compare September 19, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant