Most efficient query to get last modified record in large table

后端 未结 3 1724
说谎
说谎 2021-01-29 04:06

I have a table with a large number of records ( > 300,000). The most relevant fields in the table are:

  • CREATE_DATE
  • MOD_DATE

Those are updat

3条回答
  •  抹茶落季
    2021-01-29 04:58

    Make sure that both of those fields are indexed.

    Then I would just run -

    select max(mod_date) from table
    

    or create_date, whichever one.

    Make sure to create 2 indexes, one on each date field, not a compound index on both.

    As for a discussion of the difference between this and using limit, see MIN/MAX vs ORDER BY and LIMIT

提交回复
热议问题