-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support SQL of Prepare use SPM to bind SQL. #19824
Comments
We faced the same question. |
@superlzs0476 @gekaiwen mysql> create table t(a int, key (a));
Query OK, 0 rows affected (0.00 sec)
mysql> PREPARE stmt FROM 'select * from t where a = 40';
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE SESSION BINDING FOR select * from t where a = 1 USING select * from t ignore index (a) where a = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> EXECUTE stmt;
Empty set (0.00 sec)
mysql> explain for connection 3;
+-------------------------+----------+-----------+---------------+--------------------------------+
| id | estRows | task | access object | operator info |
+-------------------------+----------+-----------+---------------+--------------------------------+
| TableReader_7 | 10.00 | root | | data:Selection_6 |
| └─Selection_6 | 10.00 | cop[tikv] | | eq(test.t.a, 40) |
| └─TableFullScan_5 | 10000.00 | cop[tikv] | table:t | keep order:false, stats:pseudo |
+-------------------------+----------+-----------+---------------+--------------------------------+
3 rows in set (0.00 sec)
mysql> CREATE SESSION BINDING FOR select * from t where a = 1 USING select * from t use index (a) where a = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> EXECUTE stmt;
Empty set (0.00 sec)
mysql> explain for connection 3;
+------------------------+---------+-----------+---------------------+-----------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+---------------------+-----------------------------------------------+
| IndexReader_6 | 10.00 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 10.00 | cop[tikv] | table:t, index:a(a) | range:[40,40], keep order:false, stats:pseudo |
+------------------------+---------+-----------+---------------------+-----------------------------------------------+
2 rows in set (0.00 sec) |
Closing it. |
@SunRunAway BTW, we can use |
Feature Request
Is your feature request related to a problem? Please describe:
TiDB can not support bind SQL of Prepare if the application use Prepare SQL that has an incorrect execution plan, we want to use SPM to bind this type of SQL.
Describe the feature you'd like:
SPM support SQL of Prepare.
Describe alternatives you've considered:
Teachability, Documentation, Adoption, Migration Strategy:
The text was updated successfully, but these errors were encountered: