Get npoints for all transients in single query

Addresses #4234.

Note that there are actually four separate queries in the `Transient` view which may be invoked depending on the function arguments. We probably ought to make the change included in this patch to all of them. However, this change only addresses the case when we specify a dataset ID but not an image ID, which is what's happening in #4234, and which is where the main performance bottleneck can occur.