In this paper, we will discuss some optimality results for the approximation of large-scale matrix equations. In particular, this will include the special case of Lyapunov and Sylvester equations, respectively. We show a relation between the iterative rational Krylov algorithm and a Riemannian optimization method which recently has been shown to locally minimize a certain energy norm of the underlying Lyapunov operator. Moreover, we extend the results for a more general setting leading to a slight modification of IRKA. By means of some numerical test examples, we will show the efficiency of the proposed methods.