Skip to content

Add some additional database indexes#2321

Merged
alecritson merged 6 commits into1.xfrom
add_missing_database_indexes
Oct 29, 2025
Merged

Add some additional database indexes#2321
alecritson merged 6 commits into1.xfrom
add_missing_database_indexes

Conversation

@alecritson
Copy link
Collaborator

PR to add some additional database indexes to help with query speed, most notably we had a few missing on the channelables table and the deleted_at columns on products/variants.

@alecritson alecritson requested a review from Copilot October 29, 2025 08:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds database indexes to improve query performance by targeting frequently queried columns that were previously unindexed. The migration specifically addresses the channelables table (adding indexes on enabled, channelable_type, channelable_id, starts_at, and ends_at) and soft delete columns on products and product_variants tables.

Key changes:

  • Created a new migration to add indexes on multiple tables
  • Implemented PostgreSQL-specific index creation to avoid compatibility issues with MySQL and SQLite
  • Included rollback functionality to remove indexes if needed

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@glennjacobs
Copy link
Contributor

@copilot @alecritson The 'channelable_type' & 'channelable_id' fields are generally queried together. Should we consider a composite index for them?

Copy link

Copilot AI commented Oct 29, 2025

@glennjacobs I've opened a new pull request, #2322, to work on those changes. Once the pull request is ready, I'll request review from you.

@alecritson
Copy link
Collaborator Author

@copilot @alecritson The 'channelable_type' & 'channelable_id' fields are generally queried together. Should we consider a composite index for them?

That already exists

Copy link

Copilot AI commented Oct 29, 2025

@alecritson I've opened a new pull request, #2323, to work on those changes. Once the pull request is ready, I'll request review from you.

@glennjacobs
Copy link
Contributor

That already exists

What's the purpose of adding individual indexes for them then?

@alecritson
Copy link
Collaborator Author

That already exists

What's the purpose of adding individual indexes for them then?

resolved

@alecritson alecritson merged commit f2f4535 into 1.x Oct 29, 2025
45 checks passed
@alecritson alecritson deleted the add_missing_database_indexes branch October 29, 2025 09:26
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.

5 participants