Meituan-Dianping / Meituan-Dianping/SQLAdvisor
优化sql出现截断啥情况?
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 5.6k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
[root@f6-web-test opt]# sqladvisor -f sqladvisor.cnf -v 1
2017-05-24 17:01:25 15179 [Note] 第1步: 对SQL解析优化之后得到的SQL:select * AS * from (select m.pk_id AS pk_id,ifnull(m.service_subtotal,0) AS mService,ifnull(m.partinfo_subtotal,0) AS mPart,ifnull(s.servicePrice,0) AS service,ifnull(p.partPrice,0) AS part,ifnull(m.vip_expense,0) AS vip_expense,ifnull(m.czk_expense,0) AS czk_expense,m.modifiedtime AS modifiedtime from ((f6dms_1116_prod_backup.ts_maintain m left join (select id_maintain AS id_maintain,sum(subtotal) AS servicePrice from f6dms_1116_prod_backup.ts_maintain_service_detial group by id_maintain) s on((s.id_maintain = m.pk_id))) left join (select id_maintain AS id_maintain,sum(subtotal) AS partPrice from f6dms_1116_prod_backup.ts_maintain_part_detail where ((is_bring = 0) or isnull(is_bring)) group by id_maintain) p on((p.id_maintain = m.pk_id))) where ((m.is_migration = 0) and (m.is_del = 0))) a where ((abs((((a.mService + a.mpart) + a.vip_
2017-05-24 17:01:25 15179 [Note] 第2步:开始解析where中的条件:(a.modifiedtime` > '2017-04-15 00:00:00')
2017-05-24 17:01:25 15179 [Note] 第3步:表* 是临时表,不进行处理
2017-05-24 17:01:25 15179 [Note] 第4步:表* 是临时表,不进行处理
2017-05-24 17:01:25 15179 [Note] 第5步:表* 是临时表,不进行处理
2017-05-24 17:01:25 15179 [Note] 第6步: SQLAdvisor结束!
配置文件
[sqladvisor]
username=root
password=root
host=192.168.1.7
port=3306
dbname=f6dms_1116_prod_backup
sqls=SELECT * FROM(SELECT m.pk_id, IFNULL(m.service_subtotal, 0) AS mService, IFNULL(m.partinfo_subtotal, 0) AS mPart, IFNULL(s.servicePrice, 0) AS service, IFNULL(p.partPrice, 0) AS part, ifNULL(m.vip_expense, 0) AS vip_expense, ifNULL(m.czk_expense, 0) AS czk_expense, m.modifiedtime FROMts_maintainm LEFT JOIN ( SELECT id_maintain, SUM(subtotal) AS servicePrice FROM ts_maintain_service_detial GROUP BY id_maintain ) s ON s.id_maintain = m.pk_idLEFT JOIN ( SELECT id_maintain, SUM(subtotal) AS partPrice FROM ts_maintain_part_detail WHERE is_bring = 0 OR is_bring IS NULL GROUP BY id_maintain ) p ON p.id_maintain = m.pk_id WHERE m.is_migration = 0 AND m.is_del = 0) a WHERE( abs( a.mService + a.mpart + a.vip_expense - (a.service + a.part) ) > 0.01 AND a.modifiedtime > '2017-04-15 00:00:00')
select * as *也是很奇怪的

Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported sqladvisor -f sqladvisor.cnf -v 1 command with the supplied SQL and configuration. Compare the full input with the generated SQL, especially the truncated vip_expense expression and select * as *; done means the SQL is parsed and displayed without truncation or the incorrect projection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, sql
- Domain
- databases, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100