tidb: why is this sql so slow
Please answer these questions before submitting your issue. Thanks!
- What did you do? I have a sql ,i don’t know why it runs so slow. the sql is
SELECT *
FROM taxi_ride tr
WHERE tr.passenger_id = 30317977 AND tr.create_time >= '2018-08-20' AND tr.create_time < '2018-08-31'
ORDER BY tr.id DESC
LIMIT 0,20;
-
What did you expect to see? I hope this sql can runs fast in some way
-
What did you see instead? I don’t know.
-
What version of TiDB are you using (
tidb-server -V
or runselect tidb_version();
on TiDB)? v2.0.4-1
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 28 (12 by maintainers)
@guohonglei maybe you can create a new index on this table just like
alter table tr add index idx_pid_ctime(passenger_id,create_time )
and runanalyze table tr
in your mysql command line