MySQL command line vs. visual editors

Students in my training classes usually prefer to use some kind of visual editor for MySQL. Typically this would be the software they’re using at work. Sometimes they just bring over their laptops with the software installed. Or they would use MySQL Workbench, which is what I usually have pre-installed on their desktops.

I see MySQL Workbench, SQLyog, Toad for MySQL, or several more.

I always humbly suggest they close down their software and open up a command line.

It isn’t fancy. It may not even be convenient (especially on Windows, in my opinion). And repeating your last command with a minor modification requires a lot of key stroking. Or you would copy+paste from some text editor. Most students will give it a shot, then go back to their favorite editor.

Well, again and again I reach the same conclusion:

Visual editors are not as trustworthy as the command line.

Time and again students show me something on their editor. Behavior seems strange to me. Opening up a console shows a completely different picture.

Things like:

  • The visual editor would open a new connection for every new query (oh, so the @user_defined_variable I’ve just assigned turns NULL, or the TEMPORARY TABLE disappears).
  • The visual editor will only show 1,000 results, via LIMIT 0,1000. “But the same query runs so much faster on my machine!”. Well, sure, a filesort of 1,000,000 rows that can satisfy the first 1,000 will quit early!
  • The visual editor shows table definition graphically. “I didn’t realize the index did(n’t) cover this and that columns. I didn’t realize it only covered first n characters of my VARCHAR.”. That’s because you can’t beat SHOW CREATE TABLE, the definite table structure description.
  • The visual editor allows for export/import/copy/transfer of tables and rows with just one click! “Why is it so complicated in the command line to purge 1,000,000 rows from a table?”. Ummm, did you realize the visual editor would typically use a naive approach of doing everything in one huge transaction?
  • The visual editor is smart. But sometimes you don’t want smart. You just assume simple. I personally take great precaution with smart solutions. Luckily, with scripts you have so much greater control (i.e. command line options, “dry-run” mode, etc.) that I have greater confidence in them.

I do like it when a visual editor plays it both smart and safe, in such way that before doing its smart work it actually presents you with the query it’s going to issue. Which is why I always considered MySQL Query Browser (now replaced by Workbench) to be the visual editor of choice in my classes.

But, at the end of the day, I strongly believe: if you don’t know how to do it with command line, you can’t really know how it’s done.

14 thoughts on “MySQL command line vs. visual editors

  1. That’s indeed true. Caching of database and table names in visual editors is also one of the things which may get out of sync.

    There are some good uses for visual editors:
    – BLOB’s with images
    – Bug 63184: http://bugs.mysql.com/file.php?id=17712

    And there are some things which are mostly done with visual editors but which also can be done on the commandline:
    – Simple graphs SELECT REPEAT(‘=’,somevalue/100) FROM tbl WHERE …

  2. Very important and interesting points.

    I do LOVE to know more about the differences in behavior between using CLI SQL and phpMySQL (Or WB), Especially, since i use them both, depending on the nature of the task.

    It is definitely important to know how to use SQL from the CLI when you first learn SQL (and MySQL) but using it for as a roll, always, is absolutely against the idea of computers, to my opinion. Since we by using them, are always trying to find a shorter way to do a “task”. Same way as SQL is the “GUI” to getting the data in the tables instead of opening the raw tables in some hex editor. I guess.

    Again, I would defently love to know more about the short comes of the “GUI” SQL tools 🙂

  3. I fully agree that for training people should learn command line. It does exactly what you tell it to do and nothing more. But I don’t think you weighted productivity (in a non-training situation) right.

    Besides I have to object to the generalism here in this post (“GUI tools will do this_and_that”). The question is rather: exactly what GUI tools do exactly what? Can it be configured? Is it transparent for user if the tool does more that the written statement (like adding a LIMIT) if it does and what it does on a GUI operation etc. (ie: is there a complete client-side log or similar, can you preview the SQL for nontrivial operations if you want etc.)?

    This will have to be a *per tool discussion*. If not the discussion is close to ridiculous and definitely misleading IMHO.

  4. @Peter,

    I agree to some extent with your points:

    I do not argue on possible productivity gain offered by some tools, and for those who can benefit from such tools. Like I said, many prefer to use GUI tools. Of course there is a good reason for that.
    I cannot possibly cover each and every aspect of working with visual editors (syntax highlighting, drag-and drop to generate JOIN queries, in-place editing of row cells, …).

    I wanted to concentrate on the (mis)transparency of the workings of visual editors, and I think my post is very clear about exactly what it is it attempts to say. I cannot take the blame for not showing the positive sides of this and that feature set etc. This post covers one aspect which is of interest to me.

    Let’s take the particular case of SQLyog. By default it limits result sets to 1,000 rows. There’s nothing inherently wrong with that, not evil. And it is configurable. However it is confusing and misleading, in my opinion, to have a query come back so quickly when issued from the visual editor, yet so slowly from the command line.
    Not everyone has the time nor understanding of playing with all these settings.

    I can testify that on a recent class, 5 students were using SQLyog, all of them have been using it for years. To all 5 of them, the unchecking of the “Limit to 1,000 rows” checkbox was big news.

    I disagree that the discussion is close to ridiculous, since I have evidenced such misunderstandings many times, and thus think the point to which you have agreed is very important: people must learn to use the command line.
    I also add that they should keep in mind to compare results with command line.

    Regards

  5. I do not think learning process should be centered around what teacher knows. It must be more student oriented. And if students use GUI tools, and they will use them after your course, then it is good if teacher knows them as well. And does not only show the dogmatic “one true way”, i.e something teacher personally is most comfortable with.
    Also generally, I do not have much trust in posts that roughly translate to “I don’t know it. It sucks”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.