question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improvement on subquery handling in ShardingRouteDecorator

See original GitHub issue

Requisites

  1. Have the basic learning about ShardingStatementValidator
  2. Java coding

Aim-1

  1. This issue is to do some refactoring works to make the subquery validating cohesive.

How-1

  1. Create a classShardingSelectStatementValidator implements ShardingStatementValidator.
  2. Move the content of checkSubqueryShardingValues in ShardingRouteDecorator to the preValidate of ShardingSelectStatementValidator.

Once How-1 finishes, you can raize a PR. Moreover, there is a further to-do for Aim-2.

Aim-2

  1. Review the validating logic and make all the subqueries in the one database instance run well. FYI, currently, subquery only with the same sharding key can work well, which limits the subquery supported scope where we can reach.

How-2

  1. Review the preValidate function and fill the postValidate function in ShardingSelectStatementValidator to make the subqueries SQL routed in the same instance work well.
  2. Fix the @Ignore tests in SubqueryRouteTest
  3. Add a test case with a subquery SQL containing different sharding column names, like using order_id and item_id together.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
wgy8283335commented, Nov 24, 2020

@strongduanmu hi, I’ve modified the codes according to your suggestion.

0reactions
strongduanmucommented, Dec 1, 2020

I’d like to take care of aim-2.

@wgy8283335 Welcome ! 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Writing Subqueries in SQL | Advanced SQL - Mode Analytics
This lesson of the SQL tutorial for data analysis covers using subqueries ... Subqueries can be very helpful in improving the performance of...
Read more >
How to improve sub query performance in MySQL
When using sub queries, MySQL performance sucks. I have to find a better way to write my queries by analyzing them using the...
Read more >
Subqueries (SQL Server) - Microsoft Learn
A subquery is a query that is nested inside a SELECT , INSERT , UPDATE , or DELETE statement, or inside another subquery....
Read more >
Subquery vs. CTE: A SQL Primer - LearnSQL.com
SQL subqueries and CTEs seem similar, but even pros may not know all their quirks. Learn their similarities, differences, and best use ...
Read more >
13.2.10.10 Optimizing Subqueries - MySQL :: Developer Zone
Use subquery clauses that affect the number or order of the rows in the subquery. For example: SELECT * FROM t1 WHERE t1.column1...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found