Archive for the 'mysql' Category

Identifying MySQL slow queries

Thursday, December 6th, 2007

Identifying slow db queries is critical for the optimal operation of the db server. There is an excellent guide that helps to accomplish this task: http://www.ducea.com/2006/11/06/identifying-mysql-slow-queries/

Activate slow queries log

Tuesday, February 27th, 2007

If your mysql database is not as fast as it used to be, maybe it is a good idea to activate the slow queries log. Add the following lines in your .my.cnf file:

CODE:
  1. [mysqld]
  2. log_slow_queries=/var/log/mysql-slow-queries.log
  3. long_query_time=2

All the queries that take more than 2sec to execute will be logged in the /var/log/mysql-slow-queries.log file

Cakephp, mysql and utf8 problem

Friday, September 8th, 2006

Cakephp rocks. I just stared making a new site with cakephp and I already had a problem. The mysql encoding did not work properly for my language (greek). I made my database using utf8_unicode_ci but certain character appear wrong.
This is the solution:

Create a new file app_model.php, place it in your app folder. Put the following contents in the file:

PHP:
  1. class AppModel extends Model
  2. {
  3. function __construct($id=false, $table=null, $ds=null)
  4. {
  5. parent::__construct($id, $table, $ds);
  6. $this->execute( "SET NAMES 'UTF8'" );
  7. }
  8. }

if you are working with scaffolding, put this line in your cake/libs/view/templates/layouts/default.thtml:

PHP:
  1. echo $html->charset('UTF-8');

This info comes from: http://www.get-the-answer.info/comments.php?DiscussionID=5&page=1