0

I am reading the table from mysql (using python) with select query like below:

select * from tablename1 where date1= curdate();

I have 798 rows in tablename1 but it is examining more rows than existed. why?

explain select * from tablename1 where date1= curdate();

output:

    id  select_type   table        type  possible_keys  key key_len ref    rows    Extra
0   1   SIMPLE        tablename1    ALL    None         None  None  None    1039 Using where

I searched about it but I couldn't get clarity on this. how to optimize my query?

I have tried by keeping primary key but it didn't work.

James Z
  • 12,209
  • 10
  • 24
  • 44
Navya
  • 307
  • 3
  • 15
  • what does `curdate()` return? – Tom McLean Jul 06 '21 at 09:47
  • @TomMcLean, `curdate` is MySQL function that returns current date. [Docs](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_curdate) – Hermanto Jul 06 '21 at 10:09
  • 1
    Does this answer your question? [Does higher rows count in mysql explain means good or bad?](https://stackoverflow.com/questions/32986965/does-higher-rows-count-in-mysql-explain-means-good-or-bad) – Hermanto Jul 06 '21 at 10:11
  • 1
    Another reference on DBA https://dba.stackexchange.com/questions/244455/mysql-explain-gives-more-rows-then-the-count-with-where-on-the-indexed-col – Hermanto Jul 06 '21 at 10:12

0 Answers0