Skip to content

feat(taxon-tiles): improve performance and scope to collection - #8584

Open
grantfitzsimmons wants to merge 6 commits into
mainfrom
issue-303
Open

grantfitzsimmons wants to merge 6 commits into
mainfrom
issue-303

Conversation

@grantfitzsimmons

@grantfitzsimmons grantfitzsimmons commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Fixes #303

Warning

This PR affects database migrations. See migration testing instructions.

This PR makes taxon_bar collection-scoped and improves the performance of current-determination counts.

For some reason, taxon rows were filtered by collection discipline, but determination counts were not restricted to the active collection. The count query also lacked an index matching its collection-scoped predicates (so it took sooo long to complete). In the future, we should consider using Materialized Views in PostgreSQL once we migrate since this should be cached for general cases (like statistics visualizations in most contexts).

performance_tiles.mp4

Changes

  • Count only current determinations whose collectionmemberid matches the active collection.
  • Replace the previous annotation path with a correlated count lookup.
  • Add DetColMemCurrentTaxonIDX on (collectionmemberid, iscurrent, taxon).
  • Add regression coverage for determinations belonging to another collection.

User-visible changes

  • Taxon tile counts now reflect the selected collection.
  • Taxon tiles load substantially faster on large determination tables.

Performance

On the KU entomology database with 1,786,726 determinations and 42,520 taxa:

  • taxon_bar with the index: approximately 0.29–0.39 seconds.
  • taxon_bar without the index: approximately 4.10–4.22 seconds.
  • Index size: approximately 37.6 MiB at this database size, extrapolating to roughly 1 GiB at 50 million determinations.

Checklist

  • Added automated regression coverage.
  • Added the required migration.
  • Verified the migration locally by rolling it back and applying it again.
  • Reviewed the final diff for unrelated changes and debug code.
  • Link the relevant issue and add it to the release milestone.
  • Add the PR to the documentation list when appropriate.

Testing

  • Use a database that has over 1 million objects in it
  • Compare the same database on both main and issue-303 (noting that this PR introduces a migration)
  • Verify that loading taxon tiles is much faster (or at least justifiably faster)

Summary by CodeRabbit

  • Bug Fixes
    • Taxon bar counts now reflect current determinations in the selected collection, excluding noncurrent determinations and records from other collections.
  • Performance
    • Added a database index to support taxon bar count lookups.

@coderabbitai

This comment was marked as outdated.

@grantfitzsimmons grantfitzsimmons changed the title Issue 303 feat(taxon-tiles): improve performance and scope to collection Sep 26, 2026
coderabbitai[bot]

This comment was marked as outdated.

@github-project-automation github-project-automation Bot moved this from 📋Back Log to Dev Attention Needed in General Tester Board Sep 26, 2026
@grantfitzsimmons
grantfitzsimmons marked this pull request as ready for review September 26, 2026 15:37
@grantfitzsimmons

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@grantfitzsimmons

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Dev Attention Needed

Development

Successfully merging this pull request may close these issues.

Taxon tiles are not filtered by collection.

2 participants