Author Archives: OpenSorceDBA

MySQL Fabric a big hit at Texas Linuxfest

MySQL was proud to return as a sponsor of the Texas Linuxfest last weekend. Over 700 tickets sold and I probably talked to all bu two or three. Luckily I had help from Quality Assurance Guru Jeb Miller and Software Release Manager Hema Sridharan as things got very busy. The crowd was really supportive of us, MySQL, and extremely friendly.

MySQL Fabric was a popular topic of discussion. Evidently playing ‘who has the virtual IP address’ is a big problem for DevOps staffs and Fabric solves that issue. Many in attendance were on the verge of needing to shard their data and liked having a tool to manage the work for them.

And Workbench 6.1 is extremely popular. Me, “Have you seen the latest MySQL Workbench in action?” Attendee, “Yes, I use it all the time and ti has really become awesome in the last year!” Many non-DBAs who have to look after MySQL instances love the admin tools over fat finger on the command line.

So next June plan to be in Austin to see the bats come out at midnight, hear some great music on 6th Street, eat yourself silly on South Congress, and attend the best Open Source event in the Lone Star State.

2 Comments

Filed under community team, MySQL Fabric

Fabric Webinar with Andrew Morgan June 19th.

MySQL Fabric – High Availability & Automated Sharding for MySQL

MySQL Fabric is built around an extensible and open source framework for managing farms of MySQL Servers. Currently two features have been implemented – High Availability (built on top of MySQL Replication) and scaling out using data sharding. These features can be used in isolation or in combination. MySQL Fabric aware connectors allow transactions and queries to be routed to the correct servers without the need for a proxy node, so operations run as quickly as ever. MySQL FabricIn this webinar you will learn what MySQL Fabric is, what it can achieve and how it is used – by DBAs, Dev-Ops and developers. You’ll also be exposed to what is happening under the covers. In addition to the presentation, there will be live on-line Q&A with the engineering team. This is a great opportunity to learn about the latest developments directly from the people building them.

WHO:
Andrew Morgan, Principal MySQL Product Manager
Mats Kindhal, Senior Principal Software Developer
WHEN:
Thu, Jun 19: 09:00 Pacific time (America)
Thu, Jun 19: 10:00 Mountain time (America)
Thu, Jun 19: 11:00 Central time (America)
Thu, Jun 19: 12:00 Eastern time (America)
Thu, Jun 19: 13:00 São Paulo time
Thu, Jun 19: 16:00 UTC
Thu, Jun 19: 17:00 Western European time
Thu, Jun 19: 18:00 Central European time
Thu, Jun 19: 19:00 Eastern European time
Thu, Jun 19: 21:30 India, Sri Lanka
Fri, Jun 20: 00:00 Singapore/Malaysia/Philippines time
Fri, Jun 20: 00:00 China time
Fri, Jun 20: 01:00 日本
Fri, Jun 20: 02:00 NSW, ACT, Victoria, Tasmania (Australia)

The presentation will be approximately 60 minutes long followed by Q&A.
WHERE:
Simply access the web seminar from the comfort of your own office.

Register

Leave a comment

Filed under MySQL Fabric, Uncategorized, Webinar

Recruiters Looking for MySQL DBAs and MySQL Developers

Good MySQL talent is hard to find. Each day I get several ‘I am looking for a MySQL DBA’ or ‘MySQL Developer needed’. Long story short, post your opening on http://forums.mysql.com as it catches the most eyes of MySQL Professionals.

1 Comment

Filed under MySQL

MySQL at Texas Linuxfest

MySQL is proud to repeat our sponsorship of Texas Linuxfest

MySQL is a proud sponsor of the Texas Linuxfest and yes we will have Boogiebots at the booth!

MySQL is a proud sponsor of the Texas Linuxfest and yes we will have Boogiebots at the booth!

and we will again be in Austin at the convention center with BoogieBots, heavy duty luggage tags, and the latest MySQL stickers. Last week Drupalcon was in the same hall and we are returning. Plus many local MySQL employees will be in the booth to talk MySQL. So drop by to say ‘howdy’, grab a BoogieBot, and let us know your view on who has the best BBQ(1) or beer(2) in Austin.

  1. The Salt Lick
  2. Jester King

2 Comments

Filed under community team

MySQL 5.7 & Fabric in Sunnyvale May 22nd

MySQL Fabric and 5.7 will be the topics of presentations this Thursday (5/22) at the Plug and Play Tech Center in Sunnyvale, California. Lee Stigile is presenting: What’s new in MySQL 5.7, and Sastry Vendantam is presenting MySQL Fabric.

Agenda is as follows:

5:00-5:30 Networking/Socialize over food and drinks
5:30-6:00 Lee will present MySQL 5.7
6:00-6:30 Sastry will present Fabric
6:30-7:00 Q&A and Socialize over food and drinks

Here is the link to register/RSVP

Plug and Play Tech Center
Thursday, May 22, 2014 from 5:00 PM to 7:00 PM (PDT)
440 N Wolfe Rd
Sunnyvale, CA 94085

1 Comment

Filed under Uncategorized

Triggers — MySQL 5.6 and 5.7

MySQL Triggers are changing in 5.7 in a big way. Triggers have been around since 5.0 and have not changed much up to 5.6 but will gain the ability to have multiple triggers on the same event. Previously you had ONE trigger maximum on a BEFORE UPDATE, for example, and now you can have multiple triggers and set their order.

So what is a trigger? Triggers run either BEFORE or AFTER an UPDATE, DELETE, or INSERT is performed. You also get access to the OLD.col_name and NEW.col_name variables for the previous value and the newer value of the column.

So how do you use a trigger? Let say you are updating the price of an inventory item in a product database with a simple UPDATE statement. But you also want to track when the price change and the old price.

The table for products.
CREATE TABLE products (id INT NOT NULL auto_increment,
price DECIMAL(5,2) NOT NULL,
PRIMARY KEY (id));

The table for price changes on the product table.
CREATE TABLE products_log (id INT NOT NULL,
price DECIMAL(5,2) NOT NULL,
change_date timestamp);

Now to define a trigger that will log price changes. We do this when a price is updated. Now the use od OLD.price to avoid confusion between the old price or the new price being saved in the log.
DELIMITER |
CREATE TRIGGER product_price_logger
BEFORE UPDATE ON products
FOR EACH row
BEGIN
INSERT INTO products_log (id, price)
VALUES (id, OLD.PRICE);
END
|
DELIMITER ;

Add in some data.
INSERT INTO products (price) VALUES (1.10),(2.24),(.99),(.01),(.34);

So UPDATE a record.
UPDATE products SET price='1.11' WHERE ID = 1;

So did it work? Yes, and no. Running SELECT * FROM products_log; Provides us with a time stamp of the change and the OLD.price. But I forgot to also record the id!! Challenge: Correct my mistake and compare it to an update I will make in a few days.

Now 5.7 introduces multiple triggers for the same event. Lets add yet another log this time recording who made the change;

The ‘who made the change table’.
CREATE table who_changed (
id INT NOT NULL,
who_did_it CHAR(30) NOT NULL,
when_did_it TIMESTAMP);

And the second trigger.
DELIMITER |
CREATE TRIGGER product_price_whom
BEFORE UPDATE ON products
FOR EACH ROW
FOLLOWS product_price_logger
BEGIN
INSERT INTO who_changed (id, who_did_it)
VALUES (OLD.id, user());
END
|
DELIMITER ;

So UPDATE products SET price='19.99' WHERE id=4; is run and we see that both triggers execute. Note that SHOW TRIGGERS from schema; does not provide any information on trigger order. But you can find all that as action_order in PERFORMANCE_SCHEMA.TRIGGERS

Being able to order triggers makes it easy to make logical steps when processing data. Can you get into trouble with this? I am certain someone will manage to make a mess with this. But I think most of us will enjoy being able to use this great new functionality.

4 Comments

Filed under Basics, DBA Tools, MySQL, MySQL Certification, Uncategorized

MySQL in Chicago Next Week!

MySQL is the proud Training Sponsor of PHPTek. This is a great event and I am speaking on Exploiting New MySQL Features on the morning of the 23rd. See you at training day on the 19th!

And do not forget the Chicago MySQL Users Group meeting on the 21st. Yes, there will be pizza at 6:30 but RSVP so we know how much to order.

Oracle Offices
233 South Wacker Dr.
45th Floor
Chicago, IL

1 Comment

Filed under community team, MySQL

MySQL 5.6 On Google Cloud

Very happy to see this announcement “MySQL 5.6 now available in Cloud SQL: full text search, geospatial queries and online schema changes.”

2 Comments

Filed under MySQL

Foreign Keys and MySQL

Foreign Keys are often a mystery to new DBAs in the MySQL world. Hopefully this blog will clear some of this up.

In this example, we will have a table for employee data and a table for the data on offices. First we need the two tables.
CREATE TABLE employee (
-> e_id INT NOT NULL,
-> name CHAR(20),
-> PRIMARY KEY (e_id)
-> );

CREATE TABLE building (
-> office_nbr INT NOT NULL,
-> description CHAR(20),
-> e_id INT NOT NULL,
-> PRIMARY KEY (office_nbr),
-> FOREIGN KEY (e_id)
-> REFERENCES employee (e_id)
-> ON UPDATE CASCADE
-> ON DELETE CASCADE);

Those who do not use Foreign Keys will not be familiar with the last four lines of the building table. The trick is that there are two e_id columns, one in each table. In the employee table is it simply the employee identification number. However in building table, it is declared to be a foreign key to the employee table using the e_id column. The CASCADE lines are telling MySQL that any UPDATEs or DELETEs on the e_id column in employee table will also be made on the corresponding row(s) in the building table.

Add in some data .
mysql> INSERT INTO employee VALUES (10,'Larry'), (20,'Shemp'), (40,'Moe');
Query OK, 3 rows affected (0.04 sec)
Records: 3 Duplicates: 0 Warnings: 0

mysql> INSERT INTO building VALUES (100,'Corner Office',10), (101,'Lobby',40);
Query OK, 2 rows affected (0.04 sec)
Records: 2 Duplicates: 0 Warnings: 0

mysql> SELECT * FROM employee;
+------+-------+
| e_id | name |
+------+-------+
| 10 | Larry |
| 20 | Shemp |
| 40 | Moe |
+------+-------+
3 rows in set (0.00 sec)

mysql> SELECT * FROM building;
+------------+---------------+------+
| office_nbr | description | e_id |
+------------+---------------+------+
| 100 | Corner Office | 10 |
| 101 | Lobby | 40 |
+------------+---------------+------+
2 rows in set (0.00 sec)

Simple so far, right? So let us join the employee table with the building table. mysql> SELECT * FROM employee JOIN building ON (employee.e_id=building.e_id);
+------+-------+------------+---------------+------+
| e_id | name | office_nbr | description | e_id |
+------+-------+------------+---------------+------+
| 10 | Larry | 100 | Corner Office | 10 |
| 40 | Moe | 101 | Lobby | 40 |
+------+-------+------------+---------------+------+
2 rows in set (0.02 sec)

But we have three employees and only two lines of output? What happened? Well, what happened is that the query wanted the matches from both tables. To get all the rows from the first table and any matches from the second table, use a LEFT JOIN.
mysql> SELECT * FROM employee LEFT JOIN building ON (employee.e_id=building.e_id);
+------+-------+------------+---------------+------+
| e_id | name | office_nbr | description | e_id |
+------+-------+------------+---------------+------+
| 10 | Larry | 100 | Corner Office | 10 |
| 40 | Moe | 101 | Lobby | 40 |
| 20 | Shemp | NULL | NULL | NULL |
+------+-------+------------+---------------+------+
3 rows in set (0.00 sec)

Much better.

A big benefit of using foreign keys is that bad values get a lot harder to insert into the database. Try to add an office for a non-existent employ number 77.
mysql> INSERT INTO building VALUES (120,'Cubicle',77);ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`test`.`building`, CONSTRAINT `building_ibfk_1` FOREIGN KEY (`e_id`) REFERENCES `employee` (`e_id`) ON DELETE CASCADE ON UPDATE CASCADE)
mysql>

Now back to all that CASCADE stuff. Remove any of the employees from the employee table and the corresponding building entry will be removed.
mysql> DELETE FROM employee WHERE e_id=40;
Query OK, 1 row affected (0.08 sec)

mysql> SELECT * FROM employee LEFT JOIN building ON (employee.e_id=building.e_id);
+------+-------+------------+---------------+------+
| e_id | name | office_nbr | description | e_id |
+------+-------+------------+---------------+------+
| 10 | Larry | 100 | Corner Office | 10 |
| 20 | Shemp | NULL | NULL | NULL |
+------+-------+------------+---------------+------+
2 rows in set (0.00 sec)

Likewise changes are cascaded from the employee table to the building table.
mysql> UPDATE employee SET e_id=21 WHERE e_id=20;
Query OK, 1 row affected (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> SELECT * FROM employee LEFT JOIN building ON (employee.e_id=building.e_id);
+------+-------+------------+---------------+------+
| e_id | name | office_nbr | description | e_id |
+------+-------+------------+---------------+------+
| 10 | Larry | 100 | Corner Office | 10 |
| 21 | Shemp | NULL | NULL | NULL |
+------+-------+------------+---------------+------+
2 rows in set (0.00 sec)

There are many MySQL DBAs who do not use Foreign Keys for various reasons but they can be very handy. I find them useful in one to many relationships where I do not want to have to purge or change the many directly in a query.

4 Comments

Filed under Administration, Basics, MySQL

Zero to DBA track at SELF

SELF14’s Zero to DBA track is back and starts with MySQL 5.7 – What is new, what is changing, and what we are breaking. The SouthEast Linux Fest SELF 2014 has had amazing sessions and a strong database track in previous years. This year is more great content and you really need to plan on attending June 20th through the 22nd on Charlotte, NC. The social events around this show are fun and relaxed. And, after a short delay, you can see all sessions on SELF’s Youtube channel so you can really see sessions that conflict with your primary choices. This year the venue has changed to a more central location near the airport and their are lots of activities in the area for your family to enjoy in the beautiful surrounding while you get your tech itch scratched.

Leave a comment

Filed under MySQL, MySQL Community Team Event