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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to