1

Possible Duplicate:
Performing simple arithmetic in MySQL statement or in PHP code

Im wondering what is the best to use, from point of view performance:

  • PHP functions (to calculate a date in the future) and to input the date in the DB query
  • MYSQL function (to calculate a date in the future) e.g. TIMESTAMPADD(DAY,3,UTC_DATE()) directly inside the query
6
  • ... I'd vote for the db function Commented Aug 22, 2011 at 0:10
  • 2
    Determining the performance difference requires specific knowledge about how the database is constructed, which you have not provided. In any case, for consistency, for functions like this, I leave them up to the database. Unless of course it is for the presentation of data, which I leave up to PHP. Commented Aug 22, 2011 at 0:12
  • DB function. That's why it has those functions. Commented Aug 22, 2011 at 0:12
  • I just found this mysql function, i dont have any db to show you, just a general question. All my friends are stressing on the fact that i should pay attention to not overload the DB, so now im paranoic and having in mind that this function will load (just a litle bit, but still) the DB, i decided to ask. Commented Aug 22, 2011 at 0:19
  • 1
    @boris: Only, I mention where you can find addition info ... Commented Aug 22, 2011 at 0:30

1 Answer 1

2

If you're manipulating dates in a table, it's definitely better to use MySql functions. This is particularly true if the mySql server might be accessed by different hosts (which might not have their clocks all synchronized with each other).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.