tidb: why is this sql so slow

Please answer these questions before submitting your issue. Thanks!

  1. 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;
  1. What did you expect to see? I hope this sql can runs fast in some way

  2. What did you see instead? I don’t know.

  3. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)? v2.0.4-1

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 28 (12 by maintainers)

Most upvoted comments

@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 run analyze table tr in your mysql command line