为提高效率,请提供以下信息,问题描述清晰能够更快得到解决:
【 TiDB 使用环境】电商系统,生产环境
【概述】 场景 + 问题概述
订单信息根据产品名称模糊查询
【背景】 做过哪些操作
订单信息根据产品名称模糊查询
【现象】 业务和数据库现象
相同的SQL语句,TiDB查询比Mysql要慢很多
【问题】 当前遇到的问题
查询慢,请教原因
【业务影响】
【TiDB 版本】 v5.3.0
【应用软件及版本】
【附件】 相关日志及配置信息
- TiUP Cluster Display 信息
- TiUP CLuster Edit config 信息
监控(https://metricstool.pingcap.com/)
- TiDB-Overview Grafana监控
- TiDB Grafana 监控
- TiKV Grafana 监控
- PD Grafana 监控
- 对应模块日志(包含问题前后 1 小时日志)
业务SQL语句
SELECT
o.,
od.,
ue.is_email,
ue.is_liar,
IF(u.auth_phone != ‘’, 1, 0) AS is_phone,
ue.is_credentials,
p.product_name,
(
SELECT
v.email
FROM
tbl_pay_email_verify v
WHERE
v.email = od.pay_account
LIMIT
1
) AS auth_pay_account,
u.auth_phone AS phone,
ui.email AS email_ext,
ut.account AS promoter,
a.alias
,
od.origin_amount AS receive_point,
m.mdse_name,
odc.compensate_order_detail_id
FROM
tbl_order_detail AS od
LEFT JOIN tbl_order AS o ON o.id = od.order_id
LEFT JOIN tbl_order_promoter AS op ON op.id = od.detail_id
LEFT JOIN tbl_user AS u ON o.user_id = u.id
LEFT JOIN tbl_user_ext AS ue ON ue.user_id = u.id
LEFT JOIN tbl_user_info AS ui ON ui.user_id = u.id
LEFT JOIN tbl_user AS ut ON op.ad_uid = ut.id
LEFT JOIN tbl_product_web AS p ON p.id = od.product_id
AND p.site_id = od.site_id
LEFT JOIN tbl_product_alias AS a ON a.product_id = od.product_id
LEFT JOIN tbl_product_mdse AS pm ON pm.product_id = p.id
AND pm.site_id = p.site_id
LEFT JOIN tbl_mdse AS m ON m.id = pm.mdse_id
LEFT JOIN tbl_order_detail_compensate AS odc ON odc.order_detail_id = od.detail_id
WHERE
od.is_virtual = 1
AND od.create_time
>= 1451577600
AND od.create_time
<= 1644537600
AND (
p.product_name LIKE “%Football Manager 2017 Steam CD Key%”
OR a.alias
LIKE “%Football Manager 2017 Steam CD Key%”
)
ORDER BY
od.create_time DESC
LIMIT
0, 15;
SQL查询执行计划 sql查询执行计划.txt (245.3 KB)
以下截图是MySQL查询结果的时间
以下截图是TIDB服务器查询结果的时间
请问需要如何优化,能使查询速度变快?谢谢