In the newly released MySQL 5.7 labs release, users will find refactored GIS functions, as well as R-tree indexes in InnoDB. One notable change is that we have replaced a lot of the native code for geometry computation with an external library, namely Boost.Geometry. In fact, 5.7 will be the first MySQL release that depends on Boost. So why did we make such a move?
In recent years, we have seen a tremendous growth in location based services, and consequently GIS has become a strategically important area for MySQL. Our existing customers require more GIS features, and we believe this is a growing market opportunity.
Up to MySQL 5.6, GIS support in MySQL has been very limited, and the geometry algorithms implemented in MySQL were overly simple and couldn’t handle many corner cases. For example: BUG#68091, and BUG#69111.
It would have been possible to fix or rewrite the existing algorithms, but MySQL only supports the Cartesian coordinate system, and the geometry algorithms needed for handling corner cases are already complex. Once we move to oblate spheroid or 3D, it would be very challenging to implement and test the geometry algorithms on our own. After all, we are a database vendor, and computational geometry is not our field of expertise. On the other hand, relying on an external geometry library that is developed and maintained by experts will not only fix the correctness and accuracy issues we had at hand, but also provide a solid foundation for future development.
We evaluated multiple geometry libraries, and Boost.Geometry proved to fit our needs best. It had a compatible license which allows us to distribute it with our community releases. It is robust, it correctly handles corner cases, and it is fast. And finally, it has an engaging community around it. I had the pleasure of getting to know the lead developer in Boost.Geometry, Barend Gehrels. His focus on quality, attention to detail, and openness towards contributions made me confident that our cooperation will be a success.
We are not only consumers of Boost.Geometry though, we also actively contribute to it. Two of our developers, Menelaos Karavelas and Adam Wulkiewicz, both with solid experience in the field of computational geometry, work full time on enhancing Boost.Geometry to cover our needs. We then submit these enhancements upstream. We would like to see Boost.Geometry become widely adopted, and together with the rest of the Boost community, we can make it an even more feature rich product.
Along the way, we did encounter a few issues. For example, we had to change the compiler used (the Sun Studio compiler lacks the necessary C++ template support) for our MySQL builds on Solaris. See Norvald’s blog on Building MySQL with Boost for details.
GIS is a strategic and long term investment for MySQL. Our focus for now is on completing the refactoring work for the existing geometry functions and algorithms, and adopting the upcoming enhancements of Boost.Geometry. Down the road, however, we will look into support for Geography, the WGS 84 spatial reference system, projections, SRID, GeoJSON, and a lot more. As always, we highly value input from our users, so please share your thoughts and ideas with us! You can submit feature requests through the MySQL bug system, or simply comment on this blog.