avoid unnecessary inner join in get_resources() for SQL backend
avoid unnecessary inner join in get_resources() for SQL backend

To get distinct resource ids, we do a query on resource table which
inner join sample table, and apply filters on it.

Note that when sql_expire_samples_only is enabled, there will be
some resources without any sample, in such case we must use inner
join to avoid wrong result, no matter if there is a timestamp filter
or not.

But that option is disabled by default, so when there is no timestamp
filters, the inner join is unnecessary, we should avoid it to save
some RAM/CPU cost.

Change-Id: If85dbea15d42d42c6b0be7402c06f258e278b2eb
Closes-Bug: #1509677

isyippee/ceilometer,idegtiarov/ceilometer,isyippee/ceilometer,fabian4/ceilometer,fabian4/ceilometer,openstack/ceilometer,ityaptin/ceilometer,eayunstack/ceilometer,ityaptin/ceilometer,idegtiarov/ceilometer,eayunstack/ceilometer,openstack/ceilometer