Query Optimization in DBMS Query optimization plays a crucial role in ensuring the efficient and…