Often I’ve come across a piece of SQL which is hopelessly inefficient, and I need to set about optimising it. Since the rules of optimisation are pattern-based, it’d be great if a query could be dumped into a web page (perhaps with a schema to which it refers) and a number of optimisations are suggested. Even better, perhaps it could rewrite it automatically? I believe applications such as TOAD do this, but they’re pricey as well as firmly offline. Just in the same way as tools like SQLFiddle, it’d be great if this could be offered for free and without registration.
My initial thoughts are that a complex set of regular expressions, perhaps stored on a database and edited via an admin panel, would be a good way to go about this. Or, perhaps a SQL parser that converts a string into a tree would help?