`JOIN` and `AND`
The naive approach of doing the query has a problem when it comes to 'AND'
generating a query from this:
{<<"fifo">>, dproto:metric_from_list([<<"action">>, <<"count">>]), {'and', {<<"host">>, <<"sniffle@192.168.1.43">>}, {<<"service">>, <<"sniffle">>}}}
results on the following SQL statment
SELECT DISTINCT bucket, key FROM metrics JOIN tags ON tags.metric_id = metrics.id WHERE collection = $1 AND metric = $2 AND ((name = $3 AND value = $4) AND (name = $5 AND value = $6))
This will always return an empty set, as the AND
applies to the same record wich never can be true (we ask for name to be = $3 AND $5
wich is a constant false.
Not yet sure how to best solve this, we might to adjust how the query is generated