Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
时间戳日期的mySql索引_Mysql_Performance_Indexing - Fatal编程技术网

时间戳日期的mySql索引

时间戳日期的mySql索引,mysql,performance,indexing,Mysql,Performance,Indexing,我有一个时间戳列,我必须按年份过滤。我的数据库在表中大约有10000行 这是我的疑问: SELECT * FROM my_table WHERE DATE_FORMAT(my_timestamap_data, "%Y") = "2018" 如何提高我的绩效?最好的方法是创建索引 谢谢大家! 对my_timestamap_数据的简单索引: 然后查询: SELECT * FROM my_table WHERE my_timestamap >= '2018-01-01' and mytimes

我有一个时间戳列,我必须按年份过滤。我的数据库在表中大约有10000行

这是我的疑问:

SELECT * FROM my_table WHERE DATE_FORMAT(my_timestamap_data, "%Y") = "2018"
如何提高我的绩效?最好的方法是创建索引


谢谢大家!

my_timestamap_数据的简单索引

然后查询:

SELECT *
FROM my_table
WHERE my_timestamap >= '2018-01-01' and mytimestamap < 2019-01-01
选择*
从我的桌子上
其中my_timestamap>='2018-01-01'和mytimestamap<2019-01-01

如果您想知道某个索引是否会提高性能,请创建一个索引,然后从my_表中选择*年份(my_timestamap_data)=2018