getTagList: split SQL query to avoid tmp table

It is more efficient to split the getTagList query by 2:
the first fetches the tag list, and second fetches the usage (refcnt).
In this case mysql does not create a temporary table.