Skip to content

1185: Support incremental update of materialized samples view#7726

Open
labkey-nicka wants to merge 9 commits into
developfrom
fb_incremental_update
Open

1185: Support incremental update of materialized samples view#7726
labkey-nicka wants to merge 9 commits into
developfrom
fb_incremental_update

Conversation

@labkey-nicka
Copy link
Copy Markdown
Contributor

@labkey-nicka labkey-nicka commented Jun 4, 2026

Rationale

This seeks to address a portion of #1185 by introducing support for incremental update of the materialized view. The rows to update are determined by checking the modified column against a timestamp created when the mutating action is initiated. Additionally, supports incremental insert + update when it is a merge action.

Related Pull Requests

Changes

  • Add support for incremental update and incremental merge of the materialized view to ExpMaterialTableImpl
  • Update on sample change signatures to accept a changedSince timestamp parameter
  • Unit tests

Tasks

  • Claude Code Review 📍
  • Manual Testing @XingY
  • Test Automation
  • Verify Fix
Manual testing note
  • Update from detail / bulk / grid
  • Update from file
  • Update parent samples
  • Update aliquots
  • cross type update
  • Cross folder update from UI
  • File watcher
  • folder import
  • ETL?
  • merge
  • concurrent update
  • async update
  • Fail: Move samples triggers full table materialize @labkey-nicka
  • Edit any amount/status/unit trigger full table aliquot rollup sync to materialized, if there is >1 aliquot present. This is unrelated to this PR.
  • sql server

@labkey-nicka labkey-nicka self-assigned this Jun 4, 2026
Comment thread experiment/src/org/labkey/experiment/api/ExpMaterialTableImpl.java Outdated
Comment thread experiment/src/org/labkey/experiment/api/ExpMaterialTableImpl.java

private static @Nullable Timestamp captureChangedSince()
{
return new SqlSelector(DbScope.getLabKeyScope(), "SELECT CURRENT_TIMESTAMP").getObject(Timestamp.class);
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.

SQLFragment.appendNowTimestamp uses NowTimestamp (System.currentTimeMillis()). Will SELECT CURRENT_TIMESTAMP match System.currentTimeMillis() ? If not, this might result in updated data materialization skipped.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

NowTimestamp is a stand-in for CURRENT_TIMESTAMP. It is intended to be interchangeable as NowTimestamp should always be represented by the database clock when translated to SQL. I could use this instead but elected to go with the hardcoded SQL.

new SQLFragment("SELECT ").appendNowTimestamp()

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.

I remember we had to deal with SQL Server rounding issues in the past. Are both of the usages rounded in the same way?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For SQL Server, I added a 500ms buffer for the modified check. See buildIncrementalUpdateSql().

@labkey-nicka labkey-nicka force-pushed the fb_incremental_update branch from 9e3ba8b to 219f73f Compare June 5, 2026 14:23
@labkey-nicka labkey-nicka requested a review from XingY June 5, 2026 19:11
Comment thread experiment/src/org/labkey/experiment/api/ExpMaterialTableImpl.java Outdated
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