mlsamuelson.com

Topic “MySQL”

profiling queries with the MySQL Profiler

set profiling=1;

Turn the profiler on.

Now run a query or two. Then...

show profile;

To show the last profiled query.

Or...

show profiles;

To get a list of profiled queries, including durations.

Then you can...

show profile for query 4;

To show the profile for one of the listed queries.

More info on this very helpful functionality:

using FROM_UNIXTIME() to convert timestamps in your queries

SELECT FROM_UNIXTIME(access, '%Y %M') AS 'Year and Month', count(*)
FROM users GROUP BY FROM_UNIXTIME(access, '%Y %M') WITH ROLLUP;

Select all user's access times grouped by year and months with counts.

More info can be had at http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#func...

Thanks owed to Chandima for making me aware of this great function.

REPLACE() - replace text in database fields

UPDATE links SET link_description = REPLACE(link_description, 'string to replace', 'new string');

Replace strings in database fields.

Syndicate content

User login