Home |  MySQL Buzz |  FAQ |  Feeds |  Submit your blog feed |  Feedback |  Archive |  Aggregate feed RSS 2.0 English Deutsch Español Français Italiano 日本語 Русский Português 中文
Previous 30 Newer Entries Showing entries 61 to 90 of 936 Next 30 Older Entries

Displaying posts with tag: sql (reset)

SHOW PROCESSLIST in MySQL 5.6
+0 Vote Up -0Vote Down

Mark Leith writes that it’s time to say goodbye to SHOW PROCESSLIST in MySQL 5.6, and use the Performance Schema replacement for it instead, because the older tools cause some blocking, and the Performance Schema replacement is completely non-blocking.

On the face of it that’s a good thing, but I wonder whether we’ll want to keep some blocking functionality around anyway. Inspecting systems that are doing concurrent work can be hard unless you can see a variety of views on them. One such is looking at the state of all the concurrent work at an instant in time. This is sometimes indispensable for troubleshooting: you will see causes and effects you’ll never see in counters and metrics, no matter how many you capture or how sophisticated the

  [Read more...]
Percona Live CFP closing soon!
+0 Vote Up -0Vote Down

If you haven’t submitted your proposals for April’s Percona Live MySQL conference (the big annual one in Santa Clara California), now’s the time: the CFP closes in a couple of days!

Further Reading:

  [Read more...]
Changes to InnoDB autoextend coming in MySQL 5.6
+1 Vote Up -0Vote Down

I was looking through James Day’s post on upcoming changes to MySQL configuration defaults in version 5.6, and one caught my eye in particular: innodb_autoextend_increment changes from 8 to 64MB, and now affects *.ibd files.

I don’t see any further documentation on this yet; I assume that’s in the works. I’m curious how this will actually behave. What will be the initial size of an empty InnoDB table using innodb_file_per_table? There might be some unintended consequences. Here’s a couple I can think of:

  • Create a table and it’s 64MB from the start. This would cause some people to be unable to use InnoDB. In fact, as it currently stands, an empty table is 16kb, and I’ve
  •   [Read more...]
    What’s the benefit of the cloud?
    +1 Vote Up -1Vote Down

    Given that most people don’t know what the cloud is, I guess we shouldn’t be surprised that most people can’t articulate the benefits of cloud computing clearly. I commonly hear “Scalability!” “Easy provisioning!” “Flexibility!” and so on. Of course, all of these are benefits you can get without the cloud. Theo says it pretty well, so I won’t belabor that point.

    What do you think are the benefits of cloud computing?

    In the end I can think of only one really unique benefit, and it’s indirect. It is this: the rise of cloud computing is creating a social phenomenon among engineers. The benefit

      [Read more...]
    Adaptive fault detection in MySQL servers
    +1 Vote Up -1Vote Down

    I’ve just finished presenting my work on adaptive fault detection at Surge and Percona Live NYC. My slides are available on Slideshare, and embedded below.

    Adaptive Fault Detection from xaprb

    Further Reading:

      [Read more...]
    Binary log checksums in MySQL 5.6
    +2 Vote Up -2Vote Down

    MySQL 5.6 will have “checksums in the binary log,” which can be variously described, but one phrase I’ve heard a few times is, loosely, that it helps ensure replication integrity. This isn’t specific enough to make it clear what it does, and when I’ve talked about pt-table-checksum and its purpose (for example, on webinars), people often ask whether pt-table-checksum will be obsoleted by replication checksums in MySQL 5.6. The answer is no, they do completely different things. But it’s kind of confusing, a bit like semi-synchronous replication in that regard.

    pt-table-checksum ensures that your replicas have the

      [Read more...]
    Estimating column cardinality the damn cool way
    +2 Vote Up -0Vote Down

    Have you seen Damn Cool Algorithms: Cardinality Estimation yet? If not, take a few minutes and read through it. Now, what if we try using that approach instead of COUNT(DISTINCT) in MySQL to see how many distinct values there are in a column?

    I recently needed this information in real life, and the table is large with many duplicate values. The column is some 32-character hex string, a hash value that represents a session ID. I’ll call the column sess_id. I wanted to know how many distinct values it had, but I thought it would be cool (damn cool, really) to try this approach and see what happened.

    I read the blog post, convinced myself that it made sense, and tried to code it. Here’s my rough translation of the algorithm into

      [Read more...]
    My first sharded MySQL application, 5 years later
    +1 Vote Up -1Vote Down

    High Performance MySQL has a long discussion on “sharding,” examining many options and their benefits and drawbacks. What does sharding look like in the real world?

    Years ago I helped shard a MySQL-based application, partitioning its data across multiple database servers. It was already pretty large and significantly complex, so as usual for applications that aren’t designed with sharding in mind from day one, a major consideration for sharding was to make the migration strategy workable and minimize the disruption to the application code. It’s never easy to build this in after the fact, but there is a clear line between approaches that keep the business running and those that don’t.

    We chose to shard by client. Each of the major tables had a client column already, and clients could be grouped onto servers without

      [Read more...]
    Dump and reload InnoDB buffer pool in MySQL 5.6
    +2 Vote Up -0Vote Down

    After Gavin Towey’s recent blog post about Percona Server’s buffer pool dump locking the server for the duration of the operation, I thought I should re-examine MySQL 5.6′s implementation of a similar feature. When InnoDB engineers first announced the feature, I didn’t think it was complete enough to serve a DBA’s needs fully.

    If you’re not familiar with this topic, MySQL 5.6 will allow the DBA to save the IDs of the database pages that are in the buffer pool, and reload the pages later. This technique can help a server to warm up in minutes instead of hours after a restart or failover.

    I read through the

      [Read more...]
    Is automated failover the root of all evil?
    +3 Vote Up -3Vote Down

    Github’s recent post-mortem is well worth reading. They had a series of interrelated failures that caused their MySQL servers to become unavailable. The money quote:

    The automated failover of our main production database could be described as the root cause of both of these downtime events. In each situation in which that occurred, if any member of our operations team had been asked if the failover should have been performed, the answer would have been a resounding no. There are many situations in which automated failover is an excellent strategy for ensuring the availability of a service. After careful consideration, we’ve determined that ensuring the availability of our primary production database is not one of these situations.

    Most automated

      [Read more...]
    Three wishes for a new year
    +1 Vote Up -0Vote Down

    Another new year by Jewish calendar. What do I wish for the following year?

  • World peace
  • Good health to all
  • Get a decent, long waited for, implementation of Window Functions (aka Analytic Functions) for MySQL.
  • I mean, I like GROUP_CONCAT, and the many hacks it provides: [1], [2], [3], [4], [

      [Read more...]
    How to free 15GB of disk space in a tenth of a second
    +2 Vote Up -0Vote Down

    One of the MySQL servers I help manage was encountering some problems with a full data directory. It was a bit mysterious, because we couldn’t find any files to account for the increased usage. Here are some things we checked:

  • A recursive ls -l didn’t show any more, or larger, files than usual.
  • Using lsof and looking at the SIZE column didn’t either.
  • There were not enough temporary files or tables open (as shown by lsof) to account for the disk space.
  • Oddly, someone discovered that FLUSH TABLES would drop disk usage by about 15GB in a fraction of a second, allowing the server to continue running without problems.

    I carefully measured all of the items in the above list before and after FLUSH TABLES. No doubt about it: no files went away, no files

      [Read more...]
    What are MySQL’s deleted temp files?
    +2 Vote Up -0Vote Down

    If you’ve ever looked at the lsof or listing of /proc/$pid/fd for a running MySQL server, you’ve probably seen files like these:

    # ls -l /proc/$(pidof mysqld)/fd/* | grep tmp
    lrwx------ 1 root root 64 Sep 12 10:21 /proc/17222/fd/18 -> /var/lib/mysql/tmp/ibDOy0eD (deleted)
    lrwx------ 1 root root 64 Sep 12 10:21 /proc/17222/fd/323 -> /var/lib/mysql/tmp/MLhfWsbz (deleted)
    lrwx------ 1 root root 64 Sep 12 10:21 /proc/17222/fd/6 -> /var/lib/mysql/tmp/ib65H6A5 (deleted)
    lrwx------ 1 root root 64 Sep 12 10:21 /proc/17222/fd/7 -> /var/lib/mysql/tmp/ibllu2yi (deleted)
    lrwx------ 1 root root 64 Sep 12 10:21 /proc/17222/fd/8 -> /var/lib/mysql/tmp/ib9yRYwv (deleted)
    lrwx------ 1 root root 64 Sep 12 10:21 /proc/17222/fd/9 -> /var/lib/mysql/tmp/ibhUCeRO (deleted)
    

    What are those? It’s

      [Read more...]
    I always trip on level ground
    +2 Vote Up -0Vote Down

    On the lighter side: I’ve always had trouble with mysqldump’s expected syntax. You know, as the author of a book and all that, you might think I can get this to work. But pretty much every time I run this tool, it humiliates me. Witness:

    
    $ mysqldump --host localhost --password secr3t --all-databases
    Usage: mysqldump [OPTIONS] database [tables]
    OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
    OR     mysqldump [OPTIONS] --all-databases [OPTIONS]
    For more options, use mysqldump --help
    

    Alas.

    Further Reading:

      [Read more...]
    Announcing innotop 1.9.0
    +2 Vote Up -0Vote Down

    I’ve just released innotop version 1.9.0. This version fixes a lot of bugs, makes the tool work better when monitoring dozens of MySQL servers, and adds two new modes: a Health Dashboard and an InnoDB Blockers/Blocked mode.

    Further Reading:

    Measuring free space in InnoDB’s global tablespace
    +3 Vote Up -0Vote Down

    With innodb_file_per_table=1, InnoDB places every table’s data and indexes in a separate .ibd file, but there is still a “global” system tablespace, stored by default in a file named ibdata1. This contains some of each table’s data, such as the undo log and insert buffer. If it is fixed-size, you can fill it up and crash the server, as I’ve mentioned in a few recent blog posts.

    In older versions of MySQL, the SHOW TABLE STATUS command showed the amount of space free in the tablespace as an entry in the Comment column. If you weren’t using innodb_file_per_table, you could use this to see how full your tablespace was.

    The servers I’m managing use innodb_file_per_table=1, so I thought perhaps I can find out how

      [Read more...]
    Detecting MySQL server problems automatically
    +2 Vote Up -0Vote Down

    I previously blogged about work I was doing on automatically finding problems in a MySQL server, with no hardcoded thresholds or predetermined indicators of what is “bad behavior.” I had to pause my studies on that for a while, due to time constraints. I’ve recently been able to resume and I’m happy to report that I’m making good progress.

    One of the things I’ve done is a survey of existing literature on this subject. It turns out that the abnormality-detection techniques I’ve developed over the years are well-known in the operations research field. I reinvented some classic techniques used in Statistical Process Control (SPC). These include Shewhart Control

      [Read more...]
    What’s your opinion of High Performance MySQL?
    +0 Vote Up -1Vote Down

    The second edition of High Performance MySQL has 27 reviews on Amazon, but the third edition only has 5 so far. By this point I assume many of you have a copy and have read it cover to cover. I’d really appreciate your reviews — when purchasing, people look not only at the star rating but at the number of reviews. You can create a review here. And thanks!

    Further Reading:

      [Read more...]
    Staying out of MySQL’s danger zone
    +5 Vote Up -0Vote Down

    MySQL is a great database server. It has lots of flaws, but if you work with its strong points and try to minimize its weaknesses, it works fantastically well for a lot of use cases. Unfortunately, if you bang on its weak points, sometimes you get hit by falling bricks.

    A couple of its riskiest weak points relate to unavailability of an expected resource, particularly disk space and memory. For example, Stewart Smith has blogged about the interesting results you can get if you intentionally make malloc() fail. I think many of us probably have some experience with filling up the disk and causing the server to hang, breaking replication, or crashing something.

    I’m managing a couple of servers that have taught me some interesting new lessons along these lines. They use innodb_file_per_table, but their main (shared) tablespace is fixed-size, and not very

      [Read more...]
    Stuck at "copying to tmp table"
    +0 Vote Up -0Vote Down

    I have a fairly lightly loaded MySQL server with a few tables that are updated every five minutes. Other than these updates, there are very few queries run against the database. The data is queried just a few times per month. Ever so often, one of the more complicated queries will result in the process getting hung in the "copying to tmp table" state. To be honest, the queries that get hung aren't even that complicated. Usually there's one or two joins, a GROUP BY, and an ORDER BY.

    So far, when a process gets stuck in this state, I find that killing and restarting the process does not clear up the problem. I've changed my recovery method to killing the process, issuing a FLUSH

      [Read more...]
    What should a DBA do?
    +1 Vote Up -0Vote Down

    I was thinking recently about what a DBA does, and decided to blog about what I think a DBA could/should do. Most DBAs I know are mired in day-to-day firefighting and time-consuming tedium. This forces them to operate in reactive mode (because they don’t have enough time to “get caught up”), and keeps them from more valuable things they could be doing. Here’s my short and incomplete list:

  • Working with the developers (programmers) to help architect upcoming projects. If the DBA leaves design to the developers, then suboptimal designs might be found after the fact. This often happens after deploying to production, where the design impacts the business. Without early input, the DBA also has no chance to assess and prepare for future needs.
  • Teaching developers how to work with the database. Many developers struggle to understand databases
  •   [Read more...]
    MySQL: a convenient stored procedure for memory usage reporting
    +1 Vote Up -0Vote Down

    If you’ve ever been troubleshooting on the MySQL command line and needed to quickly see how much memory is being used then you’ve probably noticed that there are no built in commands to give you this data. Unlike other enterprise databases MySQL doesn’t have a very robust management system built in to help make the DBA’s life easier. It doesn’t come with built in Stored Procedures to report on usage statistics or generate handy reports; so we have to code them and import them to MySQL — no relying on Oracle to help us out here.

    So, here’s a stored procedure that can be imported to MySQL and run whenever you need to see the memory usage statistics. Installation and usage info is built into the SP below. The SP can also be downloaded from the repo:

      [Read more...]
    Dealing with deadlocks in a busy MySQL server
    +2 Vote Up -0Vote Down

    The servers I help manage have a lot of deadlocks, especially around a few central tables that are important to many business functions. The queries against them are complex, and they crunch a lot of data in some cases. As a result, we have long-running transactions that often deadlock against others, and there are even many short-running jobs that touch only a single row at a time that can’t get their work done sometimes.

    I’ve often said that deadlocks are a fact of life in transactional systems. The application must be able to deal with the deadlocks. This is true, but it’s not the whole story. The work needs to be done, unless it’s user-triggered and the user gets frustrated and abandons what they’re trying to do. That’s not the case in the applications I use; if something fails, it will get retried until it succeeds,

      [Read more...]
    MySQL kill could be so much more exciting
    +4 Vote Up -0Vote Down

    When I kill a query or connection, whoever is running it gets a boring message about what happens. Wouldn’t it be fun and useful to be able to specify the error message the user should see? Imagine the possibilities:

    mysql> KILL 10282, "Sorry, no cigar today. Try again tomorrow."
    

    Joking aside, relevant error messages would be great for all involved.

    Further Reading:

      [Read more...]
    Debugging metadata locking in MySQL 5.5
    +2 Vote Up -0Vote Down

    MySQL 5.1 added a long-needed feature: INFORMATION_SCHEMA tables for inspecting locks held and waited-for inside of InnoDB. With this addition, it became possible to figure out who is blocking whom.

    MySQL 5.5 changed a lot more things inside the server. One of the new features is improved metadata locking. This solves a lot of inconsistencies and bugs that were previously possible. The output of SHOW PROCESSLIST is also changed; instead of the venerable Locked status, there are more fine-grained status indicators such as Waiting for table metadata lock.

    Unfortunately, the additional locking is not possible for the DBA to inspect. Where

      [Read more...]
    Avoiding statement-based replication warnings
    +4 Vote Up -0Vote Down

    Although not perfect, MySQL replication was probably the killer feature that made MySQL the default database for web applications some time ago. Since then, MySQL replication has been improved greatly, with such notable changes as row-based replication. At the same time, the replication engineering team has made MySQL replication more conservative and less forgiving of foot-gun errors. These have gone a long way towards helping users avoid some of the problems that made replication sometimes drift out of sync with the master copy, sometimes silently.

    In some cases I think the strictness has gone a little too far. One example is the server’s identification of statements that are unsafe for replication because they are nondeterministic. Here is a statement in an application I manage, which is designed to claim some work from a queue. After running this

      [Read more...]
    Optimizing IN() queries against a compound index
    +2 Vote Up -0Vote Down

    Unfortunately, MySQL 5.5 doesn’t generate a very good query execution plan for IN() queries against a compound (multi-column) index, such as the following query that should be able to use the 2-column primary key:

    explain select * from tbl1
    where (col1, col2) in (
          (732727758,102),(732728118,102),(732728298,102),(732728478,102),
          (732735678,102),(962074728,102),(964153098,102),(2027956818,102),
          (2034233178,102),(2034233538,102))\G
    *************************** 1. row ***************************
               id: 1
      select_type: SIMPLE
            table: tbl1
             type: ALL
    possible_keys: NULL
              key: NULL
          key_len: NULL
              ref: NULL
             rows: 1379
            Extra: Using where
    

    Queries such as this should usually be rewritten to a form such as the following, which accesses

      [Read more...]
    A summary of changes in MySQL 5.6
    +6 Vote Up -0Vote Down

    I decided to take another look at MySQL 5.6, and realized that I’ve forgotten how many changes this version will have. Each milestone has many improvements, and there have been many milestones, so my memory of the older ones grows hazy.

    The Fine Manual has the details, but here is my attempt at a quick (and probably incomplete and inaccurate) summary. I’ve emphasized a few changes that will make life significantly better for me.

    • InnoDB: supports fulltext search; more kinds of ALTER TABLE avoid copying/rebuilding the table, some without blocking the table at all (truly online ALTER TABLE); more flexibility with data files; improvements to compression; improvements to flushing to avoid checkpointing stalls; ability to access InnoDB tables through the memcached protocol instead

      [Read more...]
    SQL: selecting top N records per group, another solution
    +1 Vote Up -0Vote Down

    A while back I presented SQL: selecting top N records per group, a "give me the top 5 countries in each continent" type of query, and which used an external numbers table and a lot of tedious casting.

    Here's another solution I came up with (*). Still using GROUP_CONCAT (how else?), but no external table and no casting. The query outputs the largest 5 countries (by surface area) per continent.

    SELECT
      Continent,
      Name,
      SurfaceArea,
      Population
    FROM
      world.Country,
      (
        SELECT 
          GROUP_CONCAT(top_codes_per_group) AS top_codes
        FROM
          (
            SELECT 
             
      [Read more...]
    A lightweight MySQL sandbox script
    +2 Vote Up -0Vote Down

    For a long time I’ve been maintaining a set of scripts inspired by Giuseppe Maxia’s MySQL Sandbox, which is a Swiss Army Knife for starting and stopping server instances for jobs such as testing, development, trying out a new version, and so on. My scripts are unpublished, until now. I’ve just kept them in my Dropbox’s bin folder, which I add to my $PATH.

    It’s not worth explaining why I use my own scripts, except for saying that I keep dozens or even more MySQL versions unpacked in my home directory at any given time, and I find it a little easier to use these lightweight scripts than the more fully-featured MySQL Sandbox tools.

    Usage assumes some conventions are followed. I “install” each version of the server by downloading the generic tarball. Then I unpack it

      [Read more...]
    Previous 30 Newer Entries Showing entries 61 to 90 of 936 Next 30 Older Entries

    Planet MySQL © 1995, 2013, Oracle Corporation and/or its affiliates   Legal Policies | Your Privacy Rights | Terms of Use

    Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.