0

I have a timestamp column and I have to filter by year. My db has about 10000 rows table.

This is my low query:

SELECT * FROM my_table WHERE DATE_FORMAT(my_timestamap_data, "%Y") = "2018"

how can I improve my performance? The best way is create an index?

thank you!

2
  • If you want to know if an index will improve performance, then create one and see Commented Feb 25, 2019 at 9:12
  • 1
    try SELECT * FROM my_table WHERE YEAR(my_timestamap_data) = 2018 Commented Feb 25, 2019 at 9:13

1 Answer 1

1

Simple index on my_timestamap_data:

And then query:

SELECT *
FROM my_table
WHERE my_timestamap >= '2018-01-01' and mytimestamap < 2019-01-01
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.