fix(dashboard): 优化经营仪表盘查询与数据库缓存
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
-- +goose Up
|
||||||
|
|
||||||
|
-- 经营仪表盘同时按买入租户、货源租户和非分销站点统计订单。
|
||||||
|
-- 覆盖索引让计数、金额汇总和最近订单不再回表扫描整张 rental_orders。
|
||||||
|
ALTER TABLE rental_orders
|
||||||
|
ADD KEY idx_rental_orders_dashboard_scope (
|
||||||
|
distribution_site_id, buyer_tenant_id, source_tenant_id, status, created_at, id
|
||||||
|
),
|
||||||
|
ADD KEY idx_rental_orders_dashboard_recent (distribution_site_id, id),
|
||||||
|
ADD KEY idx_rental_orders_buyer_dashboard (
|
||||||
|
buyer_tenant_id, distribution_site_id, status, created_at, rent_amount_cent, id
|
||||||
|
),
|
||||||
|
ADD KEY idx_rental_orders_source_dashboard (
|
||||||
|
source_tenant_id, distribution_site_id, status, created_at, source_amount_cent, id
|
||||||
|
),
|
||||||
|
ALGORITHM=INPLACE, LOCK=NONE;
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
|
||||||
|
ALTER TABLE rental_orders
|
||||||
|
DROP KEY idx_rental_orders_source_dashboard,
|
||||||
|
DROP KEY idx_rental_orders_buyer_dashboard,
|
||||||
|
DROP KEY idx_rental_orders_dashboard_recent,
|
||||||
|
DROP KEY idx_rental_orders_dashboard_scope;
|
||||||
@@ -15,6 +15,13 @@ slow_query_log = ON
|
|||||||
long_query_time = 0.5
|
long_query_time = 0.5
|
||||||
log_slow_admin_statements = ON
|
log_slow_admin_statements = ON
|
||||||
|
|
||||||
|
# 生产库热数据约 1.8GB,默认 128MB buffer pool 会让仪表盘的租户统计反复读盘。
|
||||||
|
innodb_buffer_pool_size = 768M
|
||||||
|
innodb_redo_log_capacity = 256M
|
||||||
|
innodb_io_capacity = 1000
|
||||||
|
innodb_io_capacity_max = 2000
|
||||||
|
innodb_flush_neighbors = 0
|
||||||
|
|
||||||
# 时间点恢复基础:binlog 由 scripts/archive-binlog.sh 每分钟归档到 OSS 备份桶。
|
# 时间点恢复基础:binlog 由 scripts/archive-binlog.sh 每分钟归档到 OSS 备份桶。
|
||||||
# 本地按 7 天自动过期,归档与本地保留策略见 scripts/backup-online.sh。
|
# 本地按 7 天自动过期,归档与本地保留策略见 scripts/backup-online.sh。
|
||||||
server-id = 1
|
server-id = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user