test_case
========== 1. 单表查询索引验证 ==========
EXPLAIN
-> Limit: 20 row(s)  (cost=2.85 rows=2.79)\n    -> Filter: ((t_user_health_data_202401.is_deleted = 0) and (t_user_health_data_202401.user_id = <cache>((@user_id))) and (t_user_health_data_202401.customer_id = <cache>((@customer_id))))  (cost=2.85 rows=2.79)\n        -> Index range scan on t_user_health_data_202401 using idx_health_timestamp over ('2024-01-01 00:00:00' <= timestamp <= '2024-01-31 23:59:59') (reverse), with index condition: (t_user_health_data_202401.`timestamp` between '2024-01-01 00:00:00' and '2024-01-31 23:59:59')  (cost=2.85 rows=279)\n
test_case
========== 2. UNION ALL 查询索引验证 ==========
EXPLAIN
-> Limit: 20 row(s)  (cost=150..150 rows=20)\n    -> Sort: `timestamp` DESC, limit input to 20 row(s) per chunk  (cost=150..150 rows=20)\n        -> Table scan on <union temporary>  (cost=113..117 rows=87.9)\n            -> Union all materialize  (cost=113..113 rows=87.9)\n                -> Filter: ((t_user_health_data_202401.is_deleted = 0) and (t_user_health_data_202401.user_id = <cache>((@user_id))) and (t_user_health_data_202401.customer_id = <cache>((@customer_id))) and (t_user_health_data_202401.`timestamp` between '2024-01-01 00:00:00' and '2024-03-31 23:59:59'))  (cost=31 rows=30)\n                    -> Table scan on t_user_health_data_202401  (cost=31 rows=300)\n                -> Filter: ((t_user_health_data_202402.is_deleted = 0) and (t_user_health_data_202402.user_id = <cache>((@user_id))) and (t_user_health_data_202402.customer_id = <cache>((@customer_id))) and (t_user_health_data_202402.`timestamp` between '2024-01-01 00:00:00' and '2024-03-31 23:59:59'))  (cost=31 rows=30)\n                    -> Table scan on t_user_health_data_202402  (cost=31 rows=300)\n                -> Filter: ((t_user_health_data_202403.is_deleted = 0) and (t_user_health_data_202403.user_id = <cache>((@user_id))) and (t_user_health_data_202403.customer_id = <cache>((@customer_id))) and (t_user_health_data_202403.`timestamp` between '2024-01-01 00:00:00' and '2024-03-31 23:59:59'))  (cost=31 rows=27.9)\n                    -> Table scan on t_user_health_data_202403  (cost=31 rows=300)\n
test_case
========== 3. 分页查询性能对比 ==========
EXPLAIN
-> Limit: 20 row(s)  (cost=610..610 rows=20)\n    -> Sort: `timestamp` DESC, limit input to 20 row(s) per chunk  (cost=610..610 rows=20)\n        -> Table scan on <union temporary>  (cost=293..307 rows=870)\n            -> Union all materialize  (cost=293..293 rows=870)\n                -> Filter: ((t_user_health_data_202401.user_id = <cache>((@user_id))) and (t_user_health_data_202401.customer_id = <cache>((@customer_id))) and (t_user_health_data_202401.`timestamp` between '2024-01-01' and '2024-03-31'))  (cost=31 rows=300)\n                    -> Table scan on t_user_health_data_202401  (cost=31 rows=300)\n                -> Filter: ((t_user_health_data_202402.user_id = <cache>((@user_id))) and (t_user_health_data_202402.customer_id = <cache>((@customer_id))) and (t_user_health_data_202402.`timestamp` between '2024-01-01' and '2024-03-31'))  (cost=31 rows=300)\n                    -> Table scan on t_user_health_data_202402  (cost=31 rows=300)\n                -> Filter: ((t_user_health_data_202403.user_id = <cache>((@user_id))) and (t_user_health_data_202403.customer_id = <cache>((@customer_id))) and (t_user_health_data_202403.`timestamp` between '2024-01-01' and '2024-03-31'))  (cost=31 rows=270)\n                    -> Table scan on t_user_health_data_202403  (cost=31 rows=300)\n
EXPLAIN
-> Limit/Offset: 20/180 row(s)  (cost=657..657 rows=20)\n    -> Sort: `timestamp` DESC, limit input to 200 row(s) per chunk  (cost=657..657 rows=200)\n        -> Table scan on <union temporary>  (cost=293..307 rows=870)\n            -> Union all materialize  (cost=293..293 rows=870)\n                -> Filter: ((t_user_health_data_202401.user_id = <cache>((@user_id))) and (t_user_health_data_202401.customer_id = <cache>((@customer_id))) and (t_user_health_data_202401.`timestamp` between '2024-01-01' and '2024-03-31'))  (cost=31 rows=300)\n                    -> Table scan on t_user_health_data_202401  (cost=31 rows=300)\n                -> Filter: ((t_user_health_data_202402.user_id = <cache>((@user_id))) and (t_user_health_data_202402.customer_id = <cache>((@customer_id))) and (t_user_health_data_202402.`timestamp` between '2024-01-01' and '2024-03-31'))  (cost=31 rows=300)\n                    -> Table scan on t_user_health_data_202402  (cost=31 rows=300)\n                -> Filter: ((t_user_health_data_202403.user_id = <cache>((@user_id))) and (t_user_health_data_202403.customer_id = <cache>((@customer_id))) and (t_user_health_data_202403.`timestamp` between '2024-01-01' and '2024-03-31'))  (cost=31 rows=270)\n                    -> Table scan on t_user_health_data_202403  (cost=31 rows=300)\n
test_case
========== 4. 组织级查询索引验证 ==========
EXPLAIN
-> Limit: 100 row(s)  (cost=334 rows=27)\n    -> Filter: (t_user_health_data_202401.is_deleted = 0)  (cost=334 rows=27)\n        -> Index range scan on t_user_health_data_202401 using idx_health_customer_org_time over (customer_id = 1 AND org_id = 10 AND '2024-01-01 00:00:00' <= timestamp <= '2024-01-31 00:00:00') (reverse), with index condition: ((t_user_health_data_202401.org_id = <cache>((@org_id))) and (t_user_health_data_202401.customer_id = <cache>((@customer_id))) and (t_user_health_data_202401.`timestamp` between '2024-01-01' and '2024-01-31'))  (cost=334 rows=270)\n
test_case
========== 5. 索引使用情况统计 ==========
TABLE_NAME	INDEX_NAME	SEQ_IN_INDEX	COLUMN_NAME	CARDINALITY	INDEX_TYPE
t_user_health_data_202401	idx_health_customer_org_time	1	customer_id	1	BTREE
t_user_health_data_202401	idx_health_customer_org_time	2	org_id	1	BTREE
t_user_health_data_202401	idx_health_customer_org_time	3	timestamp	100	BTREE
t_user_health_data_202401	idx_health_customer_user_time	1	customer_id	1	BTREE
t_user_health_data_202401	idx_health_customer_user_time	2	user_id	1	BTREE
t_user_health_data_202401	idx_health_customer_user_time	3	timestamp	100	BTREE
t_user_health_data_202401	idx_health_timestamp	1	timestamp	100	BTREE
t_user_health_data_202402	idx_health_customer_org_time	1	customer_id	1	BTREE
t_user_health_data_202402	idx_health_customer_org_time	2	org_id	1	BTREE
t_user_health_data_202402	idx_health_customer_org_time	3	timestamp	100	BTREE
t_user_health_data_202402	idx_health_customer_user_time	1	customer_id	1	BTREE
t_user_health_data_202402	idx_health_customer_user_time	2	user_id	1	BTREE
t_user_health_data_202402	idx_health_customer_user_time	3	timestamp	100	BTREE
t_user_health_data_202402	idx_health_timestamp	1	timestamp	100	BTREE
t_user_health_data_202403	idx_health_customer_org_time	1	customer_id	1	BTREE
t_user_health_data_202403	idx_health_customer_org_time	2	org_id	1	BTREE
t_user_health_data_202403	idx_health_customer_org_time	3	timestamp	100	BTREE
t_user_health_data_202403	idx_health_customer_user_time	1	customer_id	1	BTREE
t_user_health_data_202403	idx_health_customer_user_time	2	user_id	1	BTREE
t_user_health_data_202403	idx_health_customer_user_time	3	timestamp	100	BTREE
t_user_health_data_202403	idx_health_timestamp	1	timestamp	100	BTREE
test_case
========== 6. 表统计信息 ==========
TABLE_NAME	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	INDEX_LENGTH	data_mb	index_mb
t_user_health_data_202401	0	0	16384	49152	0.02	0.05
t_user_health_data_202402	0	0	16384	49152	0.02	0.05
t_user_health_data_202403	0	0	16384	49152	0.02	0.05
status
✅ EXPLAIN 分析完成
