Your idea of reducing id_provider to id_class using a separate query seems like a good one to me --- that will allow the planner to generate different plans depending on which id_class value is involved.
However is not a natural way to approch the problem; Am I wrong ?
Gaetano
---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster