It is possible to optimize the sql here too?