Skip to content

Correct index cardinality and performance.#89

Open
TreyE wants to merge 1 commit intotrunkfrom
polymorphic_index_performance
Open

Correct index cardinality and performance.#89
TreyE wants to merge 1 commit intotrunkfrom
polymorphic_index_performance

Conversation

@TreyE
Copy link
Copy Markdown

@TreyE TreyE commented Nov 6, 2025

Multiple indexes stored the string portion of a polymorphic association when that was not actually needed. Indexes being larger or more present than they need to be has negative effects on the performance of the database server and queries against it. These indexes were additionally on some of the largest and most-populated collections in the database.

Restructuring the indexes reduces the following issues:

  1. Bloating of the indexes to such as size as they could not easily fit in memory
  2. Frequent index ejection from memory, causing much slower query times

Further work on index reduction - such as reduction of compound indexes which already have a full prefix index provided - should be performed, but this change should deal with the worst offenders.

After deployment of this code, indexes will need a full rebuild.

Ticket - CU-868gbvfa4

Multiple indexes stored the string portion of a polymorphic association
when that was not actually needed.  Indexes being larger or more present
than they need to be has negative effects on the performance of the
database server and queries against it. These indexes were additionally
on some of the largest and most-populated collections in the database.

Restructuring the indexes reduces the following issues:
1. Bloating of the indexes to such as size as they could not easily fit
   in memory
2. Frequent index ejection from memory, causing much slower query times

Further work on index reduction - such as reduction of compound indexes
which already have a full prefix index provided - should be performed,
but this change should deal with the worst offenders.
@TreyE TreyE force-pushed the polymorphic_index_performance branch from 79d48fc to b4078e0 Compare November 6, 2025 20:51
@saikumar9 saikumar9 enabled auto-merge (squash) December 22, 2025 15:18
Copy link
Copy Markdown
Member

@saikumar9 saikumar9 left a comment

Choose a reason for hiding this comment

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

lgtm!

@saikumar9 saikumar9 requested a review from mdkaraman December 22, 2025 15:21
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