[PR #15155] [CLOSED] feat: Add performance indexes and migration script #62594

Closed
opened 2026-05-06 06:48:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/15155
Author: @decent-engineer-decent-datascientist
Created: 6/19/2025
Status: Closed

Base: devHead: dev


📝 Commits (4)

  • 23159c2 added basic indexing and a migration plan
  • 888a98c added migration plan
  • f96b8ec added the PK on tag back, whoops
  • a713e14 Merge branch 'open-webui:dev' into dev

📊 Changes

4 files changed (+82 additions, -5 deletions)

View changed files

backend/open_webui/migrations/versions/20250619_add_indexes_for_performance.py (+57 -0)
📝 backend/open_webui/models/chats.py (+15 -1)
📝 backend/open_webui/models/functions.py (+5 -1)
📝 backend/open_webui/models/tags.py (+5 -3)

📄 Description

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources? (The new migration includes a docstring with upgrade instructions).
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation? (No new dependencies).
  • Testing: Have you written and run sufficient tests to validate the changes? (Tested new installs and upgrades via migration).
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
    • feat: Introduces a new feature or enhancement to the codebase

Changelog Entry

Description

  • This feature introduces database indexes on the chat, tag, and function tables to dramatically improve query performance on large SQLite and PostgreSQL instances. For new installations, indexes are created automatically. For existing installations, a new Alembic migration script is provided to apply the indexes seamlessly, ensuring all users benefit from faster filtering and sorting operations. This resolves #15046.

Added

  • Database Performance Indexes: Added indexes to chat, tag, and function tables to accelerate common queries.
  • Database Migration Script: Included a new Alembic migration (20250619_add_indexes_for_performance.py) that allows existing users to apply the new indexes by running alembic upgrade head.

Changed

  • Updated SQLAlchemy models (Chat, Tag, Function) to declaratively define indexes, ensuring they are created on new installations.
  • The Tag model was updated to include the new performance index alongside its existing composite primary key, preserving data integrity.

Removed

  • N/A

Fixed

  • N/A

Security

  • N/A

Breaking Changes

  • N/A

Additional Information

  • For administrators of existing Open-WebUI instances, applying this update requires running the database migration to gain the performance benefits.
  • Command to apply the migration: alembic upgrade head
  • These changes are based on the performance analysis in FEATURE REQUEST (#15046).

Screenshots or Videos

  • N/A (Backend and database change)

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/15155 **Author:** [@decent-engineer-decent-datascientist](https://github.com/decent-engineer-decent-datascientist) **Created:** 6/19/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `dev` --- ### 📝 Commits (4) - [`23159c2`](https://github.com/open-webui/open-webui/commit/23159c2ab9723f3bbdf8aa3239b2a73064a03c14) added basic indexing and a migration plan - [`888a98c`](https://github.com/open-webui/open-webui/commit/888a98c090884363b0ac976d1e0842d038aee66b) added migration plan - [`f96b8ec`](https://github.com/open-webui/open-webui/commit/f96b8ecb5b64ec9807bc75f68bd905f97309a979) added the PK on tag back, whoops - [`a713e14`](https://github.com/open-webui/open-webui/commit/a713e14db86e9c3c8f5d6355b79f47f56c890eab) Merge branch 'open-webui:dev' into dev ### 📊 Changes **4 files changed** (+82 additions, -5 deletions) <details> <summary>View changed files</summary> ➕ `backend/open_webui/migrations/versions/20250619_add_indexes_for_performance.py` (+57 -0) 📝 `backend/open_webui/models/chats.py` (+15 -1) 📝 `backend/open_webui/models/functions.py` (+5 -1) 📝 `backend/open_webui/models/tags.py` (+5 -3) </details> ### 📄 Description # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request. **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? (The new migration includes a docstring with upgrade instructions). - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? (No new dependencies). - [x] **Testing:** Have you written and run sufficient tests to validate the changes? (Tested new installs and upgrades via migration). - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: - **feat**: Introduces a new feature or enhancement to the codebase # Changelog Entry ### Description - This feature introduces database indexes on the `chat`, `tag`, and `function` tables to dramatically improve query performance on large SQLite and PostgreSQL instances. For new installations, indexes are created automatically. For existing installations, a new Alembic migration script is provided to apply the indexes seamlessly, ensuring all users benefit from faster filtering and sorting operations. This resolves #15046. ### Added - **Database Performance Indexes:** Added indexes to `chat`, `tag`, and `function` tables to accelerate common queries. - **Database Migration Script:** Included a new Alembic migration (`20250619_add_indexes_for_performance.py`) that allows existing users to apply the new indexes by running `alembic upgrade head`. ### Changed - Updated SQLAlchemy models (`Chat`, `Tag`, `Function`) to declaratively define indexes, ensuring they are created on new installations. - The `Tag` model was updated to include the new performance index alongside its existing composite primary key, preserving data integrity. ### Removed - N/A ### Fixed - N/A ### Security - N/A ### Breaking Changes - N/A --- ### Additional Information - **For administrators of existing Open-WebUI instances, applying this update requires running the database migration to gain the performance benefits.** - Command to apply the migration: `alembic upgrade head` - These changes are based on the performance analysis in **FEATURE REQUEST (#15046)**. ### Screenshots or Videos - N/A (Backend and database change) ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-06 06:48:49 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#62594