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 中文
Showing entries 1 to 30 of 30

Displaying posts with tag: common_schema (reset)

Easy SELECT COUNT(*) with split()
+0 Vote Up -0Vote Down

The two conservative ways of getting the number of rows in an InnoDB table are:

  • SELECT COUNT(*) FROM my_table:
    provides with an accurate number, but makes for a long running transaction which take ages on large tables. Long transactions make for locks
  • SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='my_schema' AND TABLE_NAME='my_table', or get same info via SHOW TABLE STATUS.
    Gives immediate response, but the value can be way off; it can be two times as large as real value, or half the value. For query execution plans this may be a "good enough" estimation, but typically you just can't trust it for your own purposes.

Get a good estimate using chunks

You can get a good estimate by calculating the total number of rows in steps. Walk the table 1,000 rows



  [Read more...]
Slides from my talk: common_schema, DBA's Framework for MySQL
+1 Vote Up -0Vote Down

I've just uploaded the slides from my talk: common_schema: DBA's framework for MySQL

My talk was well attended, and I was fortunate to have a warm and engaged audience. Thank you to all those who attended, and thank you for those who provided feedback! Was happy to be able to present my work a great group of people.

You can find my slide either on Percona Live's website, or on Slideshare, as well as embedded right here.

I set two aims to my talk:

  • To have the audience know how to download and install
  •   [Read more...]
    Speaking at Percona Live 2013: common_schema, lightning talks
    +3 Vote Up -0Vote Down

    In two weeks time I will be giving these talks at Percona Live:

    • common_schema: DBA's framework for MySQL: an introduction to common_schema, my evolving server side solutions project. This will be a revised version of the talk I gave at Percona Live London; I have felt some weaknesses during that talk, which I've thrown out, letting room for cool stuff. I will discuss common_schema's various views, interesting and useful routines, the power of QueryScript, and a brief intro to the newcomer
      [Read more...]
    Taking common_schema's rdebug to a test-drive
    +1 Vote Up -0Vote Down

    This is a simple step-by-step introduction to rdebug: Debugger and Debugging API for MySQL Stored Routines, as part of common_schema.

    In other words: let me take you through the steps for debugging your stored routines on your own server. We will step into, step over, step out, modify variables, set a breakpoint, run to breakpoint...

    Command line geeks, this one's for you. GUI lovers, this is actually an API; I am hoping for someone wrap it up with a plugin for your favorite GUI editor.

    Requirements:

      [Read more...]
    common_schema 2.0.0-alpha: rdebug, GPL
    +1 Vote Up -0Vote Down

    A new release for common_schema: an alpha version of rdebug: MySQL Debugger and Debugging API is now included with common_schema.

    With a different license in mind for rdebug, common_schema changes license to GPL (2 or above).

    common_schema 2.0 is ready for download. All things rdebug, it is alpha -- otherwise it's a stable release.

    rdebug

    I'm very happy to release this alpha version of rdebug, and urge everyone to try it out.

    The idea is to have an open, free, server side debugger and debugging API for MySQL stored routines. To elaborate:

        [Read more...]
      MySQL Stored Routines Debugger & Debugging API: sneak preview II, video
      +0 Vote Up -0Vote Down

      This is the 2nd sneak preview of common_schema's rdebug: debugger & debugging API for MySQL stored routines (see 1st preview here).

      rdebug will be released as part of common_schema, free and open sourced.

      In this sneak preview I present:

      • Compiling multiple routines with debug info
      • Starting/stopping a debug session
      • Step-over, step-in, step-out
      • Showing stack trace
      • Showing the next-statement to execute
      • Viewing and manipulating local routine variables
      • Misc. meta routines

      The quick technical overview

        [Read more...]
      MySQL Stored Routines Debugger & Debugging API: sneak preview video
      +2 Vote Up -0Vote Down

      This is a sneak peek video introduction/preview of an in-development free and open source server side debugger & debugging API for MySQL stored routines.

      MySQL does not provide server side debugging capabilities for stored routines. Some tools exist, including MySQL's own, that assist in stored routine debugging. These are all GUI based and, to the best of my knowledge, MS Windows based. There is one solution in alpha stage that is developed for Java/eclipse; I did not look at the code. See discussion here and here.

      An ideal solution would be to have debugging API in the server itself - independently of your client, programming language or operating system. To the

        [Read more...]
      MySQL security tasks easily solved with common_schema
      +1 Vote Up -0Vote Down

      Here are three security tasks I handled, which I'm happy to say were easily solved with common_schema's views and routines (with no prior planning). Two are so easy, that I actually now integrated them into common_schema 1.3:

      • Duplicate a user (create new user with same privileges as another's)
      • Find users with identical set of grants (same roles)
      • Finding redundant users (users who only have privileges on non-existing objects); I was approached on this by Sheeri K. Cabral from Mozilla.

      Duplicate user

      How would you duplicate a grantee? That's easy! Just get the SHOW GRANTS output, then do text search and replace: replace the existing account (e.g. 'existing'@'localhost') with the new account (e.g.

        [Read more...]
      common_schema: 1.3: security goodies, parameterized split(), json-to-xml, query checksum
      +1 Vote Up -0Vote Down

      common_schema 1.3 is released and is available for download. New and noteworthy in this version:

      • Parameterized split(): take further control over huge transactions by breaking them down into smaller chunks, now manually tunable if needed
      • duplicate_grantee(): copy+paste existing accounts along with their full set of privileges
      • similar_grants: find which accounts share the
        [Read more...]
      common_schema over traditional scripts
      +1 Vote Up -0Vote Down

      If you are familiar with both openark kit and common_schema, you'll notice I've incorporated some functionality already working in openark kit into common_schema, essentially rewriting what used to be a Python script into SQL/QueryScript.

      What was my reasoning for rewriting good code? I wish to explain that, and provide with a couple examples.

      I'm generally interested in pushing as much functionality into the MySQL server. When using an external script, one:

      • Needs the right dependencies (OS, Perl/Python version, Perl/Python modules).
      • Needs to provide with connection params,
      • Needs to get acquainted with a lot
        [Read more...]
      Slides from my talk: common_schema, DBA's framework for MySQL
      +0 Vote Up -0Vote Down

      Thank you to all who attended my talk at Percona Live London!

      The slides from my talk are now made available, following: Slides: common_schema, DBA's framework for MySQL. Also available on slideshare.

      They should also be on the Percona Live site within a few days.

      Killing InnoDB idle transactions
      +0 Vote Up -0Vote Down

      The issue of terminating long-time idle open InnoDB transaction has been discussed recently by many. I wish to add my share, by proposing a quick and clean solution via common_schema.

      common_schema 1.2 provides with the innodb_transactions view, which relies on INNODB_TRX - one of the InnoDB Plugin views in INFORMATION_SCHEMA - as well as on PROCESSLIST, and so is able to determine with certainty that a transaction has been idle for a long time.

      innodb_transactions offers us with a sql_kill_query column, which produces a 'KILL QUERY 12345' type of value. So we

        [Read more...]
      Speaking in London: common_schema, DBA's framework for MySQL
      +1 Vote Up -0Vote Down

      I'm happy to be speaking about common_schema at Percona Live London, Dec 4th, 2012. This will be the first chance for me to speak about common_schema, what I believe to be an extremely useful companion to your MySQL server.

      I will show you how common_schema can leverage your SQL skills and give you new powers. Stuff you had to be SQL-Perl-super-expert to work through is easily attainable with common_schema and QueryScript. Some maintenance, security and auditing tasks are now a breeze. Writing server side scripts can be fun!

      What I won't do:

      • Read the fancy manual aloud
      • Walk you through every possible view,
        [Read more...]
      Purging old rows with QueryScript: three use cases
      +0 Vote Up -0Vote Down

      Problem: you need to purge old rows from a table. This may be your weekly/monthly cleanup task. The table is large, the amount of rows to be deleted is large, and doing so in one big DELETE is too heavy.

      You can use oak-chunk-update or pt-archiver to accomplish the task. You can also use server side scripting with QueryScript, offering a very simple syntax with no external scripting, dependencies and command line options.

      I wish to present three cases of row deletion, with three different solutions. In all cases we assume some TIMESTAMP column

        [Read more...]
      common_schema 1.2: security, partition management, processes, QueryScript goodies
      +1 Vote Up -0Vote Down

      common_schema 1.2 is released! This version comes shortly after 1.1, yet contains quite a few interesting goodies:

      • Account blocking
      • Security audit
      • RANGE partition management
      • Slave status
      • Better blocking and idle transaction management
      • QueryScript goodies:
        • echo, report
        • while-otherwise statement; foreach-otherwise statement
        • Better variable scope handling
        • Complete support for variable expansion
        • Transaction support within QueryScript
      • More summary info and SQL statements in processlist-related views

      A closer look at these follows:

      Account blocking

      A new view called

        [Read more...]
      Your magical RANGE partitioning maintenance query
      +0 Vote Up -0Vote Down

      If you use RANGE (or RANGE COLUMNS) partitioning, and in particular when partitioning by date/time, then your are subject to the following questions: how and when do you create the "next" partition? How and when do you drop your older partitions?

      Many people use in-house scripting to do that, and Giuseppe Maxia wrote Partition Helper. But I would like to take you one step forward, and provide with a query (based on views) which automagically understands which new partition you want to create, and provides you with the statement to do so. It looks somewhat like this (a demo follows later on):

      mysql> SELECT * FROM sql_range_partitions \G
      *************************** 1. row
        [Read more...]
      How common_schema installs itself
      +1 Vote Up -0Vote Down

      Up till common_schema version 1.1, the user would need to choose from distinct distribution files: an install compatible with MySQL 5.1, one compatible with InnoDB Plugin enabled servers, and one compatible with Percona Server. The difference between the three is the availability of certain INFORMATION_SCHEMA tables.

      With 1.1, this is no longer the case: common_schema auto-detects the server and available feature set, and installs accordingly.

      Wait, isn't common_schema just a SQL file?

      Yes. It's not like there's an installer like InstallShield or anything. Nevertheless, common_schema offers a smart way of conditional handling, which is uses in itself. It's called

        [Read more...]
      How common_schema split()s tables - internals
      +1 Vote Up -0Vote Down

      This post exposes some of the internals, and the SQL behind QueryScript's split. common_schema/QueryScript 1.1 introduces the split statement, which auto-breaks a "large" query (one which operates on large tables as a whole or without keys) into smaller queries, and executes them in sequence.

      This makes for easier transactions, less locks held, potentially (depending on the user) more idle time released back to the database. split has similar concepts to oak-chunk-update and

        [Read more...]
      Table split(...) for the masses
      +1 Vote Up -0Vote Down

      (pun intended)

      common_schema's new split statement (see release announcement) auto-splits complex queries over large tables into smaller ones: instead of issuing one huge query, split breaks one's query into smaller queries, each working on a different set of rows (a chunk).

      Thus, it is possible to avoid holding locks for long times, allowing for smaller transactions. It also makes for breathing space for the RDBMS, at times boosting operation speed, and at times prolonging operation speed at will.

      In this post I show how split exposes itself to the user, should the user wish so.

      split can

        [Read more...]
      common_schema 1.1 released: split(), try-catch, killall(), profiling
      +2 Vote Up -0Vote Down

      I'm very happy to announce the release of common_schema, version 1.1 (revision 300).

      This version boasts with compelling new features: innovative QueryScript syntax, libraries, views which add to your skills as a DBA, making some maintenance and management tasks a breeze.

      • QueryScript, split statement: automagically break long queries into smaller chunks, avoid long locks and reduce query/transaction overhead
      • QueryScript, try-catch statement: just try { something; } catch { act_on_error; }.
      • killall(): quickly kill connections based on grantee/user/host information.
      • profiling/profiling_last: utility views to assist in query
        [Read more...]
      MySQL error handling on server side: a NO GO!
      +3 Vote Up -2Vote Down

      There is no reasonable way to catch and diagnose errors on server side. It is nearly impossible to know exactly what went wrong.

      To illustrate, consider the following query:

      INSERT INTO my_table (my_column) VALUES (300);

      What could go wrong with this query?

      • We might hit a UNIQUE KEY violation
      • Or a FOREIGN KEY violation
      • my_column could be TINYINT UNSIGNED, and with strict sql_mode this makes for out-of-range
      • Or, similarly, it could be an ENUM (2,3,5,8)

      Is that it? Not remotely:

      • This could be a read-only MyISAM table
      • We may have issued a LOCK TABLES my_table READ -- this violates our lock
      • Or this could be an
        [Read more...]
      DELETE, don't INSERT
      +3 Vote Up -0Vote Down

      Have just read INSERT, Don’t DELETE by Aaron Brown, and have some lengthy response, which is why I write this post instead of commenting on said post.

      I wish to offer my counter thought and suggest that DELETEs are probably the better choice.

      Aaron suggests that, when one wishes to purge rows from some table, a trick can be used: instead of DELETEing unwanted rows, one can INSERT "good" rows into a new table, then switch over with RENAME (but please read referenced post for complete details).

      I respectfully disagree on several points discussed.

      Lockdown

      The fact one needs to block writes during the time of creation of new table is problematic: you need to essentially turn off parts of your application. The posts suggests one could

        [Read more...]
      Who is hogging my MySQL connections?
      +3 Vote Up -0Vote Down

      Got "too many connections" this morning. New attempts continuously abort. Every once in a while some slipped through, but overall behavior was unacceptable.

      max_connections is set to 500, well above normal requirements.

      Immediate move: raise max_connections to 600, some urgent connections must take place. But, this is no solution: if 500 got hogged, so will the extra 100 I've just made available.

      So, who's to blame? SHOW PROCESSLIST is so unfriendly at that. Wait. Didn't I create that view in common_schema, called processlist_per_userhost? I wonder what it says...

      SELECT * FROM
        [Read more...]
      On stored routines and dynamic statements
      +4 Vote Up -0Vote Down

      I very much enjoyed reading Overloading Procedures by Michael McLaughlin: good stuff!

      I'm dealing with similar issues in common_schema/QueryScript, where I implement a whole new scripting language within MySQL, interpreted by stored routines. I am now finalizing the next version of common_schema/QueryScript, with a major addition to the scripting language to put yet even more power at the hands of the programmer/DBA using simple, clean syntax.

      Still hush hush, the development of that feature touched at the very same issues described in Michael's post. Present in current release, these issues are intensified by the use and complexity of the new development. Here are a

        [Read more...]
      Impact of foreign keys absence on replicating slaves
      +2 Vote Up -0Vote Down

      In this post I describe what happens when a slave's Foreign Key setup is different from that of the master. I'm in particular interested in a setup where the slave has a subset of the master's foreign keys, or no foreign keys at all. I wish to observe whether integrity holds.

      Making the changes

      Which foreign keys do we have and how do we drop them? If you want to do this by hand, well, good luck! Fortunately, common_schema provides with quite a few handy views and routines to assist us. Consider viewing the existing foreign keys on sakila:

      master> SELECT create_statement FROM common_schema.sql_foreign_keys WHERE TABLE_SCHEMA='sakila';
        [Read more...]
      common_schema talk at Percona Live
      +1 Vote Up -0Vote Down

      Are you attending PerconaLive?

      Allow me to suggest you attend the Common Schema: a framework for MySQL server administration session on April 12, 14:00 - 14:50 @ Ballroom F.

      This talk is by none other than Roland Bouman. Roland co-authored parts of common_schema, and is a great speaker.

      I have a personal interest, of course, being the author of most of the components in common_schema. I would like to convert you to a supporter of this project. I know a few very smart people who think this project is an important tool. I would like more people to get to know it. Eventually, I would like developers and DBAs alike to consider it

        [Read more...]
      MySQL/QueryScript use case: DELETE all but top N records per group
      +2 Vote Up -0Vote Down

      Some administrative tasks can be simplified by using common_schema/QueryScript. I'm collecting a bunch of these for documentation. Here's one for example:

      The DBA/developer has the task of retaining only top 3 most populated countries per continent. That is, she has to DELETE 4th, 5th, 6th, ... most populated counties in each continent.

      Is it possible to work out with a single query? Yes. But the query is not pretty. In fact, it is quite complicated, and either involves unintuitive subqueries, or unintuitive hacks. A normal DBA would not want to write, neither maintain this kind of query, unless top-notch-geek, which

        [Read more...]
      common_schema rev. 218: QueryScript, throttling, processes, documentation
      +0 Vote Up -0Vote Down

      common_schema, revision 218 is released, with major new features, top one being server side scripting. Here are the highlights:

      • QueryScript: server side scripting is now supported by common_schema, which acts as an interpreter for QueryScript code.
      • Throttling for queries is now made available via the throttle() function.
      • Enhancements to processlist-related views, including the new slave_hosts view.
      • Inline documentation/help is available via the help() routine.
      • more...

      QueryScript

      common_schema makes for a QueryScript implementation for MySQL. You can run server side

        [Read more...]
      QueryScript: SQL scripting language
      +2 Vote Up -0Vote Down

      Introducing QueryScript: a programming language aimed for SQL scripting, seamlessly combining scripting power such as flow control & variables with standard SQL statements or RDBMS-specific commands.

      QueryScript is available fro MySQL via common_schema, which adds MySQL-specific usage.

      What does QueryScript look like? Here are a few code samples:

      Turn a bulk DELETE operation into smaller tasks. Throttle in between.

      while (DELETE FROM archive.events WHERE ts < CURDATE() LIMIT 1000)
      {
        throttle 2;
      }

      Convert all InnoDB tables in the 'sakila' database to compressed format:

      foreach ($table, $schema, $engine: table in sakila)
      {
        if ($engine = 'InnoDB')
          ALTER TABLE
        [Read more...]
      Documentation in SQL: CALL for help()
      +1 Vote Up -0Vote Down

      Documentation is an important part of any project. On the projects I maintain I put a lot of effort on documentation, and, frankly, the majority of time spent on my projects is on documentation.

      The matter of keeping the documentation faithful is a topic of interest. I'd like to outline a few documentation bundling possibilities, and the present the coming new documentation method for common_schema. I'll talk about any bundling that is NOT man pages.

      High level: web docs

      This is the initial method of documentation I used for openark kit and mycheckpoint. It's still valid for mycheckpoint. Documentation is web-based. You need Internet access to read it. It's in HTML

        [Read more...]
      Showing entries 1 to 30 of 30

      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.