I think everyone at least once used the explain
command or at least heard about it. This command demonstrates the query execution plan, but how exactly the DBMS arrives at it remains a mystery. And how does the DBMS understand that the selected query is optimal? Does it check all possible options?
In this article, I will try to give a little idea of how query optimizers work from a theoretical point of view.