Update The original article mentioned in this post is no longer available, but if you are still interested in query profiling in MySQL, check out this http://dev.mysql.com/doc/refman/5.0/en/show-profiles.html
I will write up an quick start guide to profiling myself here, one day.
-- original post
this article is a great way to get started using the mysql query profiler.
If you've never used it before take some time to check it out, it will change the way you think about the database forever.
Danny Angus
blog.killerbees.co.uk
Labels
Thursday, January 27, 2011
note to self, MySQL query profiler
Wednesday, January 19, 2011
Note to self, how to get the top tens from MySQL slow query log
Use these two commands to get the top ten and top ten repeaters from MySQL's slow query log.
mysqldumpslow -t 10 ./slow-log > /home/danny/top_ten_slow_query.txt
mysqldumpslow -a -s c -t 10 ./slow-log > /home/danny/top_ten_repeat_slow_query.txt
Wednesday, October 20, 2010
Note to self, how to get row numbers in a MySQL SELECT
I've often wondered, idly, how to get MySQL to output a row number column, which would rank sorted and grouped results.
Well thanks to this excellent post I've found out how:
SELECT *, @rownum:=@rownum+1 as rank FROM ( -- Your Query Goes in Here SELECT t.* FROM table t WHERE something group by 2,3,4 order by 1 desc limit 20 ) day_rank, (SELECT @rownum:=0) r;
Wednesday, September 01, 2010
note to self, how to change the definer of a mysql stored procedure
This is a useful one if, like us, you find that the account used to create the procedure doesn't have the privileges required to execute it, or perhaps you've revoked the original definers grant. (DoH!)
ALTER PROCEDURE procedure_name SQL SECURITY DEFINER;javascript:void(0)
Wednesday, August 25, 2010
note to self, how to make a mysql instance read-only
Another piece of DBA hoodoo that I seldom need!
SELECT @@global.read_only;
SET GLOBAL read_only=1;
SELECT @@global.read_only;
note to self, how to skip a mysql replication error
Another one that I have to google every time.
Not being a DBA I don't do this very often, but now and again I find myself in the Hot Seat.
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
START SLAVE;
SHOW SLAVE STATUS;
Wednesday, July 29, 2009
Failed to open the relay log
We moved some hardware about last night.
Well actually Jim and Marcin did.
This AM I got to the office to discover everything apparently working (its early days yet!) apart from one mysql replication.
Now; we've set up this replication to replicate one db using replicate-do-db which has very many of its own crazy gotcha's that I'm not going to get into here.
We also set the slave params by executing a command, rather than in my.cnf.
This allows us to meddle without having to restart mysqld, and protects us from accidentally reverting the settings if mysqld should require a restart.
my.cnf only contains the id of the slave, skip-slave-start, and replicate-do-db that affect replication.
This morning, h'wever, the slave was compaining that it couldn't open the relay log, which was annoying. I found a post here which suggested flush logs that didn't work. The next suggestion is reset slave.
Now I'm afraid of reset slave, but I didn;t think I had many options, so I forged ahead and here's how I got the job done.
NOTE-- I take no responsibility for anything misguded and foolish that you may choose to do in the light of reading this, or any other, bit of misleading nonsense on the internet.
If you have any doubts about your ability to resist doing this without putting a roll back strategy in place before hand then read no further. You have been warned!
Working completely on the slave:
1/ stop the slave .
2/ show slave status
3/ make a note of Read_Master_Log_Pos, which should equal Exec_Master_Log_Pos, and of Master_Log_File
4/ now execute reset slave
5/ now set the params you noted..
CHANGE MASTER TO MASTER_HOST='xxxx.killerbees.co.uk',
MASTER_USER='xxxx',
MASTER_PASSWORD='xxxx',
MASTER_LOG_FILE='Master_Log_File',
MASTER_LOG_POS= Read_Master_Log_Pos
6/ start slave
Job Done.
You can also use this approach to start a second slave on the same master without having to affect the master's operation:
stop slave one,
note the params,
set slave two params,
export-import the data from slave one to slave two,
start slave two.
Friday, July 04, 2008
Mysql Federated tables and Oracle Database links
Taking time out from the Big Migration job to share this with you, and before you say anything *I Know* this is old news, but forgive me because I've been away from MySQL for 4 years, and just because you know this doesn't mean that there aren't other "late adopters" like me out there.
Over the past few weeks I've come across quite a few posts on the net from folks who wanted to use oracle style links between MySQL databases (I don't need to, I just spoted a theme). Researching the storage engines in Mysql 5 (we're upgrading as well as migrating) it seems there is now an answer in the form of the Federated storage engine.
The article also provided me an answer for the perennial problem of needing several instances of MySQL in dev and test, often for exactly the task currently at hand, migrating from one version to another, that answer is the mysql sandbox. Neat. Its a shame that I've already set up my dev environment, I'd like to play with that.
Further Reading
-
Layers and Gateways, a historical view - One of the major issues in building the Internet or any large network is internetworking. If you have two networks built and run by different entities, h...3 months ago
-
[ANNOUNCE] Apache NetBeans 18 Released - The Apache NetBeans team is pleased to announce that Apache NetBeans 18 was released on May 30, 2023. What's in the Apache NetBeans 18 release: https://...1 year ago
-
The Security Failures of Online Exam Proctoring - Proctoring an online exam is hard. It’s hard to be sure that the student isn’t cheating, maybe by having reference materials at hand, or maybe by substit...3 years ago
-
ApacheCon@Home 2020 - Myrle Krantz has added a photo to the pool: [image: ApacheCon@Home 2020]3 years ago
-
-
GTID implementation - Oracle vs MariaDB - Oracle MySQL has implemented GTID differently from MariaDB; this article walks through some of the key differences. Before we look at the details, let’s ...5 years ago
-
ApacheCon Seville 2016 – Building a Container Solution on Top of Apache CloudStack- Steve Roles - Building a Container Solution on Top of Apache CloudStack- Steve Roles Cloud native applications running in containerised environments look set to create a...7 years ago
-
Nóirín Plunkett - https://www.flickr.com/photos/robertburrelldonkin/5729816462 smiles and socks retreating in co. wicklow now empty whiskey and secrets bar camping in ox...9 years ago
-
Hello world! - Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!9 years ago
-
Debugging MySQL Slow Queries With Many Joins - This week I encountered an issue that I hadn’t seen in a while. The ORM in a CMS project that I work on automatically joins to many subclass tables, causin...11 years ago
-
You’re invited to help us celebrate an unlikely pairing in open source - We are just days away from reaching a significant milestone for our team and the open source and open standards communities: the first anniversary of Micro...11 years ago
-
Boat For Sale - Boat For Sale: Price: £150 Terms and Conditions Oracle reserve the right to alter the web price of this acticle even after purchase. Price does n...17 years ago
-
-
-
-
I know nothing, I'm not a fortune teller, and you'd be insane to think that I am. This disclaimer was cribbed from an email footer I once received. It is so ridiculous I had to have it for myself.
Statements in this blog that are not purely historical are forward-looking statements including, without limitation, statements regarding my expectations, objectives, anticipations, plans, hopes, beliefs, intentions or strategies regarding the future. Factors that could cause actual results to differ materially from the forward looking statements include risks and uncertainties such as any unforeseen event or any unforeseen system failures, and other risks. It is important to note that actual outcomes could differ materially from those in such forward-looking statements.
Danny Angus Copyright © 2006-2013 (OMG that's seven years of this nonsense)