tags:

views:

17

answers:

1
date_default_timezone_set('America/Guayaquil');
$cnn->execute('SET NAMES utf8');
$cnn->execute('SET GLOBAL time_zone = "-5:00"');

Hi, the code above is run everytime someone enters the website im developing. Does someone know what the impact (in performance) of those commands is?

+1  A: 

Of the PHP date_default_timezone_set command: negligible

Of the two MySQL commands: Unlikely to be significant.

Don't you mean SET SESSION rather than SET GLOBAL? If you're doing it for just the connection...

Edit: To expand on my answer, I have a script that gets included from just about every PHP script on my site that sets various configurations like date_default_timezone_set, starts sessions, defines functions and so on. It also sets the SQL mode to "TRADITIONAL" with the database connection. I think setting some configuration options is something you shouldn't try to avoid.

Hammerite
thanks! i actually meant GLOBAL based on what i read. What would be the difference, though?
andufo
As per: http://dev.mysql.com/doc/refman/5.1/en/set-option.html two significant differences are: 1) "The SUPER privilege is required to set global variables." 2) "If you change a session system variable, the value remains in effect until your session ends or until you change the variable to a different value. ... If you change a global system variable, the value is remembered and used for new connections until the server restarts." Based on what your apparent desired behaviour, SET SESSION is what you want.
Hammerite