[PR #5241] [CLOSED] perf(db): index group_name and client_traffics hot columns #5827

Closed
opened 2026-11-02 04:04:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5241
Author: @n0ctal
Created: 6/12/2026
Status: ❌ Closed

Base: main ← Head: codex-pr-0007-db-hot-path-indexes


📝 Commits (1)

  • 499304a perf(db): index group_name and client_traffics hot columns

📊 Changes

3 files changed (+44 additions, -3 deletions)

View changed files

➕ internal/database/index_tags_test.go (+41 -0)
📝 internal/database/model/model.go (+1 -1)
📝 internal/xray/client_traffic.go (+2 -2)

📄 Description

Summary

This PR adds the missing hot-path database indexes for:

  • client_records.group_name
  • client_traffics.inbound_id
  • client_traffics.last_online

These columns are used frequently in filtering, grouping, and traffic-related reads, but were not indexed.

Why

On larger datasets, these lookups become unnecessarily expensive and increase query latency for common panel operations.

This change keeps the schema behavior the same while improving read performance on existing and future databases.

Scope

  • adds index tags for the three hot columns
  • relies on the existing migration / AutoMigrate flow
  • no behavioral change

Validation

  • added/updated tests to assert the indexes exist after migration
  • validated with database tests

Risk

Low. This is a schema/index improvement only and does not change application logic.


🔄 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/MHSanaei/3x-ui/pull/5241 **Author:** [@n0ctal](https://github.com/n0ctal) **Created:** 6/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `codex-pr-0007-db-hot-path-indexes` --- ### 📝 Commits (1) - [`499304a`](https://github.com/MHSanaei/3x-ui/commit/499304a0fa08de1538f3ac41400468d797501af9) perf(db): index group_name and client_traffics hot columns ### 📊 Changes **3 files changed** (+44 additions, -3 deletions) <details> <summary>View changed files</summary> ➕ `internal/database/index_tags_test.go` (+41 -0) 📝 `internal/database/model/model.go` (+1 -1) 📝 `internal/xray/client_traffic.go` (+2 -2) </details> ### 📄 Description ## Summary This PR adds the missing hot-path database indexes for: - `client_records.group_name` - `client_traffics.inbound_id` - `client_traffics.last_online` These columns are used frequently in filtering, grouping, and traffic-related reads, but were not indexed. ## Why On larger datasets, these lookups become unnecessarily expensive and increase query latency for common panel operations. This change keeps the schema behavior the same while improving read performance on existing and future databases. ## Scope - adds index tags for the three hot columns - relies on the existing migration / AutoMigrate flow - no behavioral change ## Validation - added/updated tests to assert the indexes exist after migration - validated with database tests ## Risk Low. This is a schema/index improvement only and does not change application logic. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:22 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5827
No description provided.