What schema changes should I make to support tracking page views?

#1

I have a few queries that do not work due to the limitations of tag values and the inability to group by fields. The only field I have at the moment is an integer that can be used for a sum aggregate to get a total of page views.

Currently, these items are what I planned to have tagged in the measurement:
uri - Could have hundreds of thousands of values (won’t work, it reaches tag limits)
referrer - Could have millions of values (same as above)
domain - Could have several values so this works
I would also have a field (count) which I could sum up in a query with a where clause that uses those tags.

The queries I want to support are:
SELECT SUM(count) FROM views WHERE time >= 1466845200000000000 AND time <= 1466845300000000000 GROUP BY referrer
SELECT SUM(count) FROM views WHERE time >= 1466845200000000000 AND time <= 1466845300000000000 GROUP BY domain, uri

I would also like to support ordering by aggregates like SUM, but that does not seem to be supported right now, so I can simply sort my results after I’ve retrieved them.

Are there any workarounds to satisfy this schema? The biggest issue is that I need to group by items that have too many values to be tags, but not supported if they were fields.