You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "ShayneLee8 (via GitHub)" <gi...@apache.org> on 2024/10/18 06:18:17 UTC
[I] Getting wrong results when using "explain sql" in Sharding-Proxy 5.5.0, database is MySQL 5.7 [shardingsphere]
ShayneLee8 opened a new issue, #33292:
URL: https://github.com/apache/shardingsphere/issues/33292
Sharding-Proxy 5.5.0
Mysql 5.7
this is sharding config

Using explain

Without explain

When I don't have "explain" I get the correct STORAGE UNIT,
When I add "explain" I get the wrong STORAGE UNIT, why is this happening,
I want to get the correct ds_2, how can I do it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Getting wrong results when using "explain sql" in Sharding-Proxy 5.5.0, database is MySQL 5.7 [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu commented on issue #33292:
URL: https://github.com/apache/shardingsphere/issues/33292#issuecomment-3640525784
## Issue Understanding
- Sharding-Proxy 5.5.0 + MySQL 5.7, sharding algorithm ds_${ monthtime >= '2024-10' ? 2:0 }. A plain SELECT ... WHERE monthtime='2024-10' routes to ds_2, but adding EXPLAIN returns ds_0. You want the proxy to show the correct shard.
## Root Cause
- In the proxy, EXPLAIN is parsed as a DAL statement and routed via unicast (no sharding condition evaluation), typically choosing the first or current connection’s data source. This is by design and not a sharding-aware preview.
## Analysis
- To inspect sharding routing and rewritten SQL at the proxy layer, use DistSQL PREVIEW <SQL> instead of EXPLAIN. Official doc: docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rul/preview-sql.en.md.
- PREVIEW returns data_source_name and actual_sql, so you can see ds_2 and the rewritten SQL. For the physical execution plan, run EXPLAIN directly on the target shard.
- The master branch still treats EXPLAIN as DAL unicast; no change there yet.
## Conclusion
- This is expected behavior, not a fixed bug. Use DistSQL PREVIEW SELECT ... to view routing in the proxy, and run EXPLAIN on the target shard to see the execution plan.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Getting wrong results when using "explain sql" in Sharding-Proxy 5.5.0, database is MySQL 5.7 [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #33292: Getting wrong results when using "explain sql" in Sharding-Proxy 5.5.0, database is MySQL 5.7
URL: https://github.com/apache/shardingsphere/issues/33292
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org