lwk595ww opened a new issue, #21114:
URL: https://github.com/apache/shardingsphere/issues/21114

   Condition: I am using compound sharding and I am using a custom sharding 
strategy.
   
   The SQL statement:  select t10.* from user t10  where t10.id in (select 
t11.user_id from school t11 where t11.id = 1571685907277340673 and t11.tenantId 
= 'caba6901') and t10.tenantId = 'caba6901'
   
   Test conclusion: This SQL removes the custom policy, but returns two result 
sets in the source code. One is the table name returned by the custom sharding 
policy, and one is the table name returned by the full sharding, which results 
in a Cartesian product between the primary table and the child table
   
   
![image](https://user-images.githubusercontent.com/64793990/191462563-54b51686-16aa-4a60-86e6-ad60ed56e0a6.png)
   
   
![image](https://user-images.githubusercontent.com/64793990/191463377-4b6dd515-898e-42bf-ad67-da7a4133ce95.png)
   
   
![image](https://user-images.githubusercontent.com/64793990/191463417-e6bdd961-a3e2-48a6-9514-ba47a62ca148.png)
   
   
![image](https://user-images.githubusercontent.com/64793990/191463580-1566c5e9-757a-48e3-81aa-7a53b298ad8c.png)
   
   
![image](https://user-images.githubusercontent.com/64793990/191463813-6b8b9eab-0430-49a9-b297-93eec80573b9.png)
   
   
   The above figure shows that under the same logical table, the conditions of 
two logical tables are cycled, causing the logical table cannot match the 
logical table name of the conditions, and the framework returns full sharding
   
   The last figure shows that after the SQL is decomposed by the framework, 
each decomposed SQL matches all the sharding conditions, resulting in each 
logical table returning two sets of real tables, which, when merged, becomes a 
full sharding lookup.
   
   
![image](https://user-images.githubusercontent.com/64793990/191464449-75feed1f-c67d-4af2-850e-85561a28c8c0.png)
   
   Can you determine whether different conditions belong to different logical 
tables at this point in the source code, to avoid conditions that do not belong 
to this logical table also walk the logic, resulting in full fragmentation
   


-- 
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