OpenGL and Workbench Canvas News

Recently, a bug that caused excessive memory usage and slowness (specially in large models) in Workbench has been fixed in its canvas. From the testing I’ve done, the speed for displaying diagrams seems to scale much better and dragging around tables in large models is doable in an acceptable speed. This fix is in the upcoming releases of the 5.0 and 5.1 alpha versions of Workbench.

Apart from that, we’ve been doing some work on reintroducing OpenGL support to the Workbench canvas. Unlike the initial implementation, this time OpenGL is used directly instead of going through Cairo’s experimental (and not quite reliable) support through the Glitz layer. This means that in machines with a recent graphics card, hardware acceleration will be used and working with large diagrams will be a lot smoother and faster. Of course, software rendering backends (GDI+, Quartz and Xlib) will still be supported and used in case OpenGL is not the best option.

We still use Cairo to render everything (or most things) as before, but now the pre-rendered object bitmaps are uploaded to the video card and displayed through textures. Although the “software” rendering we were using was also hardware accelerated in most cases (because GDI+ et al are implemented with acceleration by the OS), using OpenGL textures seems much faster than blitting these bitmaps to screen in the old way. Naturally, this also opens the door for some totally useless and cool eye candy ūüôā But that’s for after we get the essentials done…

There are still problems to be worked out (some of the transparencies are not working well and there are some refreshing glitches), but you can try it with the --force-opengl-render option.

Printing in Workbench

A common misunderstanding seems to be that the only way to increase the available “paper space” for a diagram is by increasing the size of the paper. But there is another way to do that, which is in the Model -> Diagram Size dialog, where you can set the number of pages your diagram has, vertically and horizontally (perhaps it’s not very obvious to first time users, so we’ll be working on making it more easily accessible).

model menu

diagram size

Another recurring issue is that of printing in the community version. Direct printing is currently only available in Workbench SE, but that doesn’t mean you cannot print using the OSS version. You can still export the model to a variety of formats, like PDF, PNG and SVG. And once you export as an image you can print it with any tool that can handle such files, like Acrobat Reader or something similar.

On the Workbench Canvas Performance

Some people might have noticed that Workbench runs very slowly and flickers a lot in their machines. Other people will be able to work without noticing any significant sluggishness with the diagram graphics. The difference is because Workbench’s custom canvas may use hardware accelerated OpenGL graphics or non-accelerated software rendering, depending on the system (ie, whether or not a 3D accelerated graphics card is available or not). We were expecting that the most reasonably recent machines (maybe 5 years old or less) would have at least some basic graphics acceleration, but for some reason, that seems to not always be the case. Apparently, some people that have decent systems with ATI or Intel cards seem to get the fallback software rendered canvas, which will result in sluggish graphics.

We are still not sure why Cairo/Glitz (the underlying graphics library used by our drawing canvas) is not working as intended for everyone, but we are working on getting this performance problem solved in at least two fronts:

  • one is to add support for the Windows GDI backend of Cairo, which seems to be faster than the software based OpenGL rendering provided by Mesa. We already use that for Windows printing, so we get that for almost free;
  • another thing that’s being worked on is general drawing optimization, so that the number of redundant drawing operations is minimized. Those changes should make Workbench work much faster and smoother for everyone, as we intended to have from the beginning.

So expect future versions to have an improved canvas and Workbench will be much faster when you work on larger models.

Tell me what your code looks like…

Code line distribution over all projectsFrom time to time it is necessary to get a bigger picture of your project in terms of size, test coverage, code vs. comments ratio and others (aka metrics). While it is quite difficult to find a good (and free) code coverage tool for C++ there is already a very nice tool package called DPack, which is not only freely available but also gives us some very useful additions in our IDE. One of those features is code statistics.

Continue reading “Tell me what your code looks like…”

MySQL Workbench: Lua Plugin Support

The Lua plugin support has been finally fixed and will be working in the next release. Together with a few other improvements, it’s now possible to write your own commands to do all kinds of tasks. Documentation for the plugin system is not yet written (and the previous one is outdated), but it should be straightforward to copy the supplied Lua plugin and change it to do something else. All you need is to know a little Lua (which is a simple scripting language) and explore Workbench internals using the GRT Shell (View -> Advanced -> GRT Shell).The sample Lua plugin is located in the modules folder. You can copy it to the custom plugins folder which is shown in the GRT Shell at startup and change things like the module name and add your own functions. I’ll write more about how to write such functions in a future post, like after the next WB is actually released.There are a few ways that plugins can be accessed, including just calling them from the GRT Shell, from the main menus (which you can change in the main_menu.xml file or in a menu editor when its written) or from context menus for the objects that the plugin supports. In fact, most functionality of Workbench works the same way as plugins, so there’s a lot that can be done.

What’s new in MySQL Workbench 6.2

The new MySQL Workbench version 6.2 has its usual share of new¬†features but also¬†brings¬†some big improvements that will be very welcome even to long time¬†users that only need the bread and butter basic functionality. Here’s the list:

Spatial Data Viewer

MySQL 5.7 will include much awaited GIS support for InnoDB tables. To make it easier to quickly visualize spatial/geometry data in geographic context, Workbench 6.2 includes a viewer for resultsets containing that type of data. The viewer will render data from each row as a separate clickable element. When clicked, you can view the rest of the data from that row in the textbox. If you have multiple queries with geometry data, you can overlay them in the same map. spatial_viewer

Geometry Data Viewer

Both the Field and Form Editors were updated to support the GEOMETRY datatype. You can view geometry data like polygons from a single row as an image or as text, in any of the common WKT, GeoJSON, GML or KML formats. form_editor

MS Access Migration

MS Access support was added to the¬†Migration Wizard in MySQL Workbench 6.2, joining¬†MS SQL Server, Sybase ASE, Sybase SQL Anywhere, PostgreSQL, SQLite and “Generic ODBC” as migration sources. You can read more about it in¬†How-To: Guide to Database Migration from MS Access using MySQL Workbench.

Metadata Lock Browser

MySQL uses metadata locking to manage access to objects (tables, triggers, and so forth). Sometimes that can be puzzling, as your query may block waiting on an object being manipulated by another connection from maybe another user. The Client Connections list was updated to take advantage of the metadata lock information provided in the performance_schema starting in MySQL 5.7.3, to show information about what locks a connection is waiting for and what it holds. client_connections_locks

Updated Client Connection Browser

Speaking of the Client Connection browser, a neat feature added in MySQL 5.6 is the connection attribute dictionary, which includes handy things like the name of the clients that are connected (as long as the client supports it). You can access that by clicking the Show Details button in the Client Connection screen. client_connections

Improved Visual Explain

In MySQL 5.7, the Optimizer Team has been doing great work in refactoring as well as innovation with the new Cost Model. The improved Visual Explain enables the DBA to now get deeper insights into Optimizer decision making, for improved performance tuning of queries. explain   The UI was also improved to allow easier navigation in large query plans.

Streamlined Query Results Panel

The query results panel was updated to centralize the many features related to result sets into a single location. Result Grid, Form Editor, Field Types, Query Stats, Execution Plan (including the traditional and Visual Explain) and the new Spatial Viewer are all easily accessible from a single interface. Screenshot 2014-09-05 14.35.39

Shared Snippets

SQL Snippets are useful to store queries and commands that are used often, but until now they could¬†only be stored locally. In 6.2, you can now store snippets in the MySQL server you’re connected to and anyone anywhere who¬†can access the .mysqlworkbench schema can also use these snippets.

MySQL Fabric Support

MySQL Fabric servers can now be added to the Workbench home screen. When clicked, these connections will dynamically query the Fabric server and individual connections for all the managed MySQL servers will be created. You can then connect to each instance as usual. Screenshot 2014-09-08 15.24.30

Run SQL Script

It often happens that people try to load gigantic SQL script files into the Workbench SQL editor just to execute them. That will rarely work, as loading files for editing uses a lot of memory and Workbench does a lot of processing in the editor (syntax highlighting, syntax checking, code folding etc). To execute arbitrarily large scripts easily, you can now use the dialog at File -> Run SQL Script: Screenshot 2014-09-05 14.48.35 ¬† The dialog lets you preview a part of the script, specify a default schema¬†(in case¬†it’s not already defined) and a default character set to use when importing it. The output window shows warnings, messages and a nice progress bar.

Include Model Scripts in Forward Engineering and Synchronization

Workbench modeling has always supported attaching SQL script files to the model, usually for documentation/organization purposes. You can now include these attachments to the output script when performing forward engineering or synchronization. Screenshot 2014-09-05 14.55.35

Direct Schema Tree Action Buttons

Screenshot 2014-09-05 15.00.21 The schema tree in the SQL Editor now has some very convenient buttons for accessing the most used functions for each object type:

  • Table or¬†Schema Inspector
  • Object structure¬†editor
  • Table data browser/editor
  • Call Stored Procedure or¬†Function

Format Note Objects in Diagrams

Note objects in diagrams can now be resized and have its contents automatically rearranged. You can also change style attributes like font, background color and text color. Screenshot 2014-09-05 15.07.27

Other improvements and bug fixes that make a difference

Resultset grid columns are now automatically resized to fit Рand if you manually resize a column, the customized size is remembered, so next time you run that query again, the columns will be back to the size you left them.

Customize font for resultset grid Рsome people want to cram more text in the resultset grid, some people prefer bigger, easier to read text. Now you can pick what you like in Preferences.

Improved state saving for the SQL Editor РOpened, closed and reordered tabs are now properly saved and restored. The scroll position and cursor location is also remembered.

MySQL password is remembered for the session, even if not stored in the keychain, so you don’t need to re-enter it when¬†a new connection is needed.

Keyboard shortcuts now work in the Scripting Shell.

Resume data copy in Migration Wizard. If a data copy fails during database migration (because of a timeout or network failure, for example), you can now click Resume to retry the data copy. Workbench will find the last row that was copied successfully and try to restart the copy from that row.

Platform Updates

MySQL Workbench 6.2 also finally adds native 64bit support for Windows. This should allow working with larger data sets and script files. Oracle Linux/RHEL 7 support was added. To improve quality and user experience, we will be providing 64-bit binaries for Linux. Linux users who want 32-bit binaries, can compile from source.