What is the best way to write performant queries if you are using a lot of the attributes_string_val...
a
What is the best way to write performant queries if you are using a lot of the attributes_string_value column in your query? For example something like this:
Copy code
SELECT
    attributes_string_value[indexOf(attributes_string_key, 'customer')] AS customer,
    formatDateTime(fromUnixTimestamp64Nano(timestamp), '%Y-%m-%d %H:%i') AS timestamp_utc,
    attributes_string_value[indexOf(attributes_string_key, 'request')] AS request,
    COUNT(*) AS requests
FROM signoz_logs.distributed_logs
WHERE ((attributes_string_value[indexOf(attributes_string_key, 'log.file.name')]) = 'test.log') 
AND (request LIKE '%/api/headsup%') 
AND (timestamp >= {{.start_timestamp_nano}}
AND timestamp <= {{.end_timestamp_nano}})
GROUP BY
    customer,
    timestamp_utc,
    request
ORDER BY requests DESC
it starts to get slow if we select more than 1 hour of data, and ideally this query can run smoothly for 1 day
s
Use the old logs explorer to make the fields "Selected". It will materialize the columns cleanly and then you can use it in a query. In the above query it has to unpack and read all attributes even if they are not needed.