Query optimization in init()