BZ1073093 Alert template query does not scale well

With a high number of alert definitions, the count query does not scale well.

Adding index for resource_type_id