[BUG] — Systemic missing secondary indexes across the admin schema
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
- severity: High; files: `shenyu-admin/src/main/resources/sql-script/h2/schema.sql` and `db/init/mysql/schema.sql`
- description: Beyond PKs, the schema defines almost no secondary indexes. The only ones are `proxy_api_key_mapping.idx_namespace_enabled`, `discovery_upstream.discovery_upstream_discovery_handler_id_IDX`, `plugin_handle.plugin_id_field_type`, `shenyu_dict.dict_type_dict_code_dict_name`, `dashboard_user.user_name`, plus a few unique keys. Every other join/where column is unindexed, specifically: `selector(namespace_id, plugin_id, selector_name)`, `rule(namespace_id, selector_id, rule_name)`, `meta_data(path, namespace_id, app_name, service_name)`, `app_auth(app_key, namespace_id)`, `auth_path(auth_id)`, `auth_param(auth_id)`, `permission(object_id, resource_id)`, `data_permission(user_id, data_id, data_type)`, `tag_relation(api_id, tag_id)`, `api(api_path, http_method, rpc_type, context_path, state, date_created)`, `api_rule_relation(api_id, rule_id)`, `namespace_plugin_rel(namespace_id, plugin_id, enabled)`, `discovery_rel(proxy_selector_id, selector_id, discovery_handler_id)`, `discovery_handler(discovery_id)`, `discovery(namespace_id, plugin_name)`, `proxy_selector(namespace_id)`, `operation_record_log(operation_time, operator)`, `instance_info(namespace_id, instance_ip)`, `mock_request_record(api_id)`, `namespace_user_rel(namespace_id, user_id)`, `user_role(user_id, role_id)`, `resource(parent_id)`.
- impact: All WHERE/JOIN/ORDER BY predicates above fall back to full table scans; compounds PERF-A1..A8.
- suggested_fix: Add the listed composite secondary indexes (DDL in both H2 and MySQL schema files).
- confidence: High
---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/00-consolidated-critical-high.md`](docs/scan2-2026-08-02/00-consolidated-critical-high.md)._
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with shenyu-admin/src/main/resources/sql-script/h2/schema.sql and db/init/mysql/schema.sql, then consult docs/scan2-2026-08-02/00-consolidated-critical-high.md for the consolidated list. Compare the existing indexes with the listed WHERE, JOIN, and ORDER BY columns, and consider both schema dialects. Done means the requested composite secondary indexes are present consistently in both schema files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, sql
- Domain
- databases, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100