When you're spoiled with Oracle's fabulous query transformation capabilities and its really well-done cost-based optimiser, then you might forget how difficult SQL query tuning used to be in the "old days" or with those less sophisticated databases. Here's a really nice explanation of the various means of implementing an ANTI-JOIN in MySQL: http://explainextended.com/2009/09/18/not-in-vs-not-exists-vs-left-join-is-null-mysql/
I have seen a few posts on DBA.SE (where I answer a lot of questions) recommending the use of semi-synchronous replication in MySQL 5.5 over a WAN as a way to improve the reliability of replication. My gut reaction was that this is a very bad idea with even a tiny write load, but I wanted to test it out to confirm. Please note that I do not mean to disparage the author of those posts, a user whom I have great respect for.
What is semi-synchronous replication?
The short version is that one slave has to acknowledge receipt of the binary log event before the query returns. The slave doesn’t have to execute it before returning control so it’s still an asynchronous commit. …
[Read more]The MySQL developer tools team announces the availability of version 5.2.41 of the MySQL Workbench GUI tool. This version has significant improvements in several parts of the tool and also includes the new Migration Wizard plugin.
The new Migration Wizard presents an easy to use GUI for migrating databases from third party products to MySQL. In this initial release, support for Microsoft SQL Server is included, in addition to other products that support ODBC, such as PostgreSQL.
Other improvements include:
- More than 100 bug fixes
- Code completion in the SQL Editor (beta)
- Better handling of schema synchronization in modeling
For a full list of issues fixed in this release, see http://dev.mysql.com/doc/workbench/en/changes-5.2.x.html
Please get your copy from our Downloads …
[Read more]If you haven’t checked into pt-online-schema-change yet, now’s a great time to sign up for my free webinar Thursday, July 19, 3-4 PM EDT. I’ll explain and demonstrate the tool, and walk you through everything you need to decide whether it’s right for you.
If you haven’t even heard about pt-online-schema-change yet, the short version is it lets you alter tables in MySQL with practically no downtime at all. This even works for really big tables that might take hours or days to alter — normally a blocking operation. In fact, 37Signals just wrote a blog post saying it has helped them achieve 99.99% uptime for their Basecamp …
[Read more]One of the more notable success stories of the open source world is in the field of databases. A company with a strong commitment to open source has seen tremendous growth and success in the enterprise while contributing to a hugely respected open source code base. Who is that? Maybe your first thought was MySQL, now owned by Oracle. But unlike MySQL, this company is actually taking business away from Oracle so effectively that it's seen an 80 percent revenue growth in the last year.
I was stunned when a SQL query raised an ERROR 1630
(42000)
telling me the SUM
function didn’t
exist in MySQL 5.5.23. The fix was simple. The opening
parenthesis of the SUM
function must be on the same
line as the SUM
keyword without an intervening white
space. Alternatively phrased, you can’t have a line return or
white space between the SUM
function name and the
opening parenthesis of the call parameter list. The same rule
doesn’t apply to the opening parenthesis of the
FORMAT
function and it seems to me that this parsing
inconsistency is problematic.
Therefore, my surprise, observation, and complaint is
that all functions don’t parse the same way, using the same
rules. That is, unless you use specialized SQL_MODE
settings. This assumption was borne out by Kolbe
Kegel’s comment on this post, and there are 30 …
This post isn’t about NuoDB, although it was prompted by the phrase “100% uptime” that I’ve seen them use a few times. I want to suggest that people think slightly differently about uptime and availability.
The key to understanding uptime and thinking clearly about it, in my opinion, is to think instead about downtime. Uptime is the absence of downtime. Therefore, focus your attention on reducing downtime through a two-pronged approach. First, increase the mean time between failures (MTBF). Second, reduce the mean time to recovery (MTTR) when downtime happens. The techniques for achieving these goals are quite different; the second tends to be a technical solution, whereas the first usually requires a management solution.
Now, back to uptime. Is 100% uptime even possible? It depends on how you define it. Play funny with the definition, and you can draw a box around a period on your timeline where there was no downtime. …
[Read more]I’ve been working on a data archival project over the last couple weeks and thought it would be interesting to discuss something a bit counter-intuitive. Absolutes are never true, but when getting rid of data, it’s usually more efficient to insert the data being kept into a new table rather than deleting the old data from the existing table.
Here is our example table from the IMDB database.
mysql> show create table title\G *************************** 1. row *************************** Table: title Create Table: CREATE TABLE `title` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` text NOT NULL, `imdb_index` varchar(12) DEFAULT NULL, `kind_id` int(11) NOT NULL, `production_year` int(11) DEFAULT NULL, `imdb_id` int(11) DEFAULT NULL, `phonetic_code` varchar(5) DEFAULT NULL, `episode_of_id` int(11) DEFAULT NULL, `season_nr` int(11) …[Read more]
In my database class, students write solutions as group exercises against the Oracle 11g XE database and then they port the solution individually to the MySQL 5.5 database. One of the students copied over a query like the one below to MySQL (a query used to track the expected number of row returns).
SELECT COUNT(*) FROM (SELECT DISTINCT k.kingdom_id , kki.kingdom_name , kki.population FROM kingdom_knight_import kki LEFT JOIN kingdom k ON kki.kingdom_name = k.kingdom_name AND kki.population = k.population);
It got an error they didn’t understand:
ERROR 1248 (42000): Every derived TABLE must have its own alias
Providing a dt
query alias fixes the problem in
MySQL for the following query. The fact that it was just an alias
was a revelation to the student. That’s because Oracle databases
don’t require aliases …
Somebody wanted to understand why you can backquote a single
wildcard operator (that’s the underscore _
character) in MySQL, but can’t in Oracle. The answer is you can
in Oracle when you know that you required an additional clause.
While I prefer using regular expression resolution, the
LIKE
operator is convenient. Here’s an example of
backquoting an underscore in MySQL, where it looks for any string
with an underscore anywhere in the string:
SELECT common_lookup_type FROM common_lookup WHERE common_lookup_type LIKE '%\_%';
You can gain the same behavior in Oracle by appending the
ESCAPE '\'
clause, like this:
SELECT common_lookup_type FROM common_lookup WHERE common_lookup_type LIKE '%\_%' ESCAPE '\';
The ESCAPE '\'
clause is one of those Oracle details
that often gets lost. It only works when the SQL*Plus
ESCAPE
…