SQL optimizations

These SQL optimizations made it possible to import OSM data of Benelux scale.