-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
enhance range calculation upon user variables #8733
Comments
Thanks for your feedback, we will take a look @laizhebujum |
confirmed that this problem still exists in release 4.0 and the latest master branch at this time: TiDB(root@127.0.0.1:test) > create table t(a bigint, b bigint, index idx(a));
Query OK, 0 rows affected (0.00 sec)
TiDB(root@127.0.0.1:test) > desc select * from t where a > 1 and a < 10;
+-------------------------------+---------+-----------+----------------------------------------------------------------+
| id | estRows | task | operator info |
+-------------------------------+---------+-----------+----------------------------------------------------------------+
| IndexLookUp_10 | 250.00 | root | |
| ├─IndexRangeScan_8(Build) | 250.00 | cop[tikv] | table:t, index:a, range:(1,10), keep order:false, stats:pseudo |
| └─TableRowIDScan_9(Probe) | 250.00 | cop[tikv] | table:t, keep order:false, stats:pseudo |
+-------------------------------+---------+-----------+----------------------------------------------------------------+
3 rows in set (0.00 sec)
TiDB(root@127.0.0.1:test) > set @a = 1;
Query OK, 0 rows affected (0.00 sec)
TiDB(root@127.0.0.1:test) > set @b = 10;
Query OK, 0 rows affected (0.00 sec)
TiDB(root@127.0.0.1:test) > desc select * from t where a > @a and a < @b;
+-------------------------+----------+-----------+------------------------------------------------------------------------------+
| id | estRows | task | operator info |
+-------------------------+----------+-----------+------------------------------------------------------------------------------+
| Selection_5 | 8000.00 | root | gt(cast(test.t.a), cast(getvar("a"))), lt(cast(test.t.a), cast(getvar("b"))) |
| └─TableReader_7 | 10000.00 | root | data:TableFullScan_6 |
| └─TableFullScan_6 | 10000.00 | cop[tikv] | table:t, keep order:false, stats:pseudo |
+-------------------------+----------+-----------+------------------------------------------------------------------------------+
3 rows in set (0.01 sec) |
This is because
We can only fold the |
/pick-up |
Pick up success. |
@asiafrank You did not submit PR within 7 days, so give up automatically. |
/pick-up |
Pick up success. |
@asiafrank You did not submit PR within 7 days, so give up automatically. |
/pick-up |
Pick up success. |
Description
Compare two sqls
1、
SET @execDate = DATE_FORMAT(NOW(),'%Y-%m-%d');
SET @start_time = DATE_ADD(NOW(), INTERVAL -1 DAY);
SET @end_time = @execDate;
desc SELECT count(*) FROM GameActiveLogDB.wendao_active_log WHERE active_time >= @Start_time AND active_time < @End_time;
2、desc SELECT count(*) FROM GameActiveLogDB.wendao_active_log WHERE active_time >= DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -1 DAY),'%Y-%m-%d') AND active_time < DATE_FORMAT(NOW(),'%Y-%m-%d');

Score
900
SIG slack channel(must):
Contact us in channel
#sig-planner
of TiDB CommunityMentor(must)
The text was updated successfully, but these errors were encountered: