Which is better MAX function or ORDER BY column_name DESC with LIMIT 1 I have one scenario where I want to have max value on date column,

eg. for table

CREATE TABLE IF NOT EXISTS `sample_table` (
  `id` TINYINT UNSIGNED NOTNULL,
  `name` VARCHAR(45) NOT NULL,
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARYKEY(`id`))
ENGINE = InnoDB;


So I used a query as below:

SELECT MAX(created_at) AS latest FROM sample_table;


But I was suggested to index created_at column and use following query for faster result

SELECT created_at FROM sample_table ORDER BY created_at DESC LIMIT 1;


I am clueless which is best way to do so? If second query is better, than why there is inbuilt MAX function
Add an index on created_at and use your first query:

SELECT MAX(created_at) AS latest FROM sample_table;


The suggestion you got is good in other situations, like if you want a max value of a field that is smaller than certain value. i.e. 

SELECT created_at FROM sample_table WHERE created_at&lt;"2014-01-01 00:00:00" ORDER BY created_at DESC LIMIT 1;