Skip to content

Make materialized query more helpful - #8000

Open
labkey-jeckels wants to merge 1 commit into
release26.7-SNAPSHOTfrom
26.7_fb_materializedQuery
Open

Make materialized query more helpful#8000
labkey-jeckels wants to merge 1 commit into
release26.7-SNAPSHOTfrom
26.7_fb_materializedQuery

Conversation

@labkey-jeckels

Copy link
Copy Markdown
Contributor

Rationale

Analysis shows that our current 1 hour retention for materialized tables is way too short for sample type scenarios. Additionally, without doing an analyze the DB may not be making good query plan choices.

Changes

  • Update retention from 1->12 hours as an incremental testing step
  • ANALYZE materialized table as part of its creation

Tasks

  • Claude Code Review
  • Manual Testing
  • Test Automation - N/A

@labkey-jeckels
labkey-jeckels requested review from a team, XingY and labkey-matthewb August 31, 2026 04:37
@labkey-jeckels labkey-jeckels self-assigned this Aug 31, 2026

@labkey-nicka labkey-nicka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main thing to test is that this analyze does not take exceedingly long to execute for large tables.

}

static final BlockingCache<String,_MaterializedQueryHelper> _materializedQueries = CacheManager.getBlockingStringKeyCache(CacheManager.UNLIMITED, CacheManager.HOUR, "materialized sample types", null);
// TTL is a backstop for missed invalidations. Admins can manually clear via Admin Console->Caches

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Comment is true for all of our caches. I feel its not worth mentioning here.

}
}

/** SELECT INTO leaves the table with no statistics, so the planner guesses until autovacuum eventually analyzes it. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, TIL that running ANALYZE after SELECT INTO or CREATE TABLE AS is considered standard practice in Postgres.

@labkey-nicka labkey-nicka added this to the 26.07 milestone Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants