Does indexing a date column improve performance?

I have a table with millions of rows where one of the columns is TIMESTAMP and against which I often choose for date ranges. Will it improve the performance of anyone to index this column, or will it not provide any noticeable improvements?

EDIT:

So, I indexed the TIMESTAMP column. Next request select count(*) from interactions where date(interaction_time) between date('2013-10-10') and date(now())

Takes 3.1 seconds.

The interaction table contains more than 3 million records.

The above query gives the result ~ 976k

Does this seem like a reasonable amount of time to complete this task?

+5
source share
5 answers

, :

  • .

  • -, , , sargable, . , . :

    WHERE interaction_time >= '2013-10-10' 
      AND interaction_time < (CURRENT_DATE + INTERVAL 1 DAY)
    
+14

, :

  • ""
  • , , ""

, EXPLAIN, , . - , . , , .

.

+2

select count(*) from interactions where date(interaction_time) between date('2013-10-10') and date(now())

:

  • interaction_time date(interaction_time)
  • , interaction_time
  • () '2013-10-10' not date('2013-10-10')

# 1, , , .

+1

- , .

, , , SELECT. ( , .)

(.. ) , . , . - . , , , , , , , . , , , . , , .., . - EXPLAIN, , mySQL .

+1
source

Adding an index to a date column definitely improves performance.

My table has 11 million rows, and the query to fetch rows that were updated to a specific date took the following time according to the conditions:

Without index: ~ 2.5 s

With index: ~ 5 ms

0
source

All Articles