Building an 'industrial strength' implementation of AQL on SQL is an interesting challenge, which may possibly be the next step for the AQL project. It's tricky not only because of optimization issues like you identify in your post, but because SQL doesn't perfectly match AQL's semantics (e.g., SQL uses three valued logic). If you'd like to get involved, please let me know!