I have a table with a certain column say created_time with datatype as datetime. It is also one of the primary key on that table.
Now when I try to query a date range created_time BETWEEN :startTime AND :endTime , it ends up looking through the entire table as I can see from the execution plan.
Now, there is another primary key column sensor_time with data type as INT which stores the time in unix format. When I use the range in this, it only looks through the database for a small subsection.
Please someone explain me why the range does not work efficiently with the datetime type even though it is a primary key.
datetime. I have corrected it.