Query optimizer hotfixes

Back to: