Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6378371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:59:47+00:00 2026-05-25T01:59:47+00:00

Suppose I have a table ‘Tasks’ with a DATETIME column approve_time . I have

  • 0

Suppose I have a table ‘Tasks’ with a DATETIME column approve_time. I have an index on said column.

If I were to write a query of the form:

SELECT task_id, task_desc, task_owner, approve_time 
  FROM Tasks
 WHERE DATE(approve_time) = '2011-08-31'

My question is about the performance of such a query:

Does MYSQL index DATETIME columns in a way that allows constraining by the date component to be fast?

Or does MYSQL know how to optimize the query into something like the following?

WHERE approve_time >= '2011-08-31 00:00:00'
  AND approve_time <  '2011-09-01 00:00:00'

Or does the query incur a tablescan?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:59:48+00:00Added an answer on May 25, 2026 at 1:59 am

    Does MYSQL index DATETIME columns in a way that allows constraining by the date component to be fast?

    NO

    Or does MYSQL know how to optimize the query into something like the following?

    YES


    the second query will lead to range filter,
    try

    explain extended query_1; <--- number of rows sent for scan is more, 
                                   which should be aLL rows
    

    vs

    explain extended query_2;
    

    the value of DATE(approve_time) only can determined after the function applied to column approve_time in all the row, which mean there is not going to make use on index

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a table called Companies that has a DepartmentID column. There's also
Suppose I have database table TABLE1 and there is Column COLUMN1 . The variable
Suppose you have a table widget class. Do you do table.row(i).column(0).setText(students[i].surname()) or table[0][i] =
Suppose we have a table Users that has only one column UserId which is
Suppose I have a table with the column Description, varchar(100). If try to insert
Suppose I have one table table1 and another table table2. Both has same column
Suppose I have a table a with one column b and three rows(1,2,3), I
Suppose I have table A with a field that can be either 1 or
Suppose I have table Person table Employee, which inherits Person. I want to get
Suppose we have a table A: itemid mark 1 5 2 3 and table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.