Mysql datetime field partial match Currently I am designing a mysql table structure that will hold a couple of million rows. 
I want to search in it on datetime field by date year and so on but the date will be entered by user so it may not be full date all the time. The field is indexed. 
Will it be fast enough to use wildcard on the datetime field. Like so

SELECT `id`, `moment`, `object_uid`, `content` FROM `events` WHERE moment like '2015%';


Will it use the index?

There is an option to determine whether or not the user have entered year or month and year and so on but I prefer to let MySQL do the job.

SQLfiddle
It's hard to say if your query will use the index or not because that will be based on what MySQL's optimizer decides is best based on your data distribution and statistics.

In any case, a wildcard at the end is Sargable, so at least the wildcard isn't what's preventing your index usage.
See for example this post by Brent Ozar or this by Rob Farley

On the other hand, if you search for year only my guess would be the query won't be selective enough to use an index, year and month might but that's hard to tell.

See my reply to this question for an explanation: Why is the SQL Server query plan not using indexes in a query almost similar to one that uses indexes?
It's a SQL Server question but the same principle applies.


  Since SQL server reads entire pages, and not records, your query (as 
  indicated by statistics) needs to be selective enough for the index to
  be  used, if SQL server estimates that it's going to have to read
  every page  anyway it will go for a table scan.