0

I'm working on RedisSearch queries, I wonder about SlowLog. When my keys are more than 500k , all of my queries log as SlowLog, even the following simple Aggregate query:

FT.Aggregate roomDailySpecs-idx * GroupBy 1 @RoomId Reduce AVG "1" @Price as avg_price Filter @avg_price>30000

I want to know, why that query is slow , Can it depends on Hardwares like Ram or CPU?

A. Guy
  • 500
  • 1
  • 3
  • 10
iman safari
  • 194
  • 1
  • 1
  • 8

1 Answers1

3

The SLOWLOG log records all queries and commands that took more than slowlog-log-slower-than ms threshold, which is 10 ms by default. You can read more about this configuration here. You can set the threshold to some larger value to catch only very slow executions.

The query you included might be simple, but it requires to scan the entire document table in your index. In addition to that, if you didn’t mark the @RoomId and @Price fields as SORTABLEs, it also requires to load the values from the redis key space for every document. From the docs:

SORTABLE - NUMERIC, TAG, TEXT, or GEO attributes can have an optional SORTABLE argument. As the user sorts the results by the value of this attribute, the results are available with very low latency. Note that his adds memory overhead, so consider not declaring it on large text attributes. You can sort an attribute without the SORTABLE option, but the latency is not as good as with SORTABLE.

You can read more about SORTABLE fields here.

In conclusion, if you wish to not see the FT.AGGREGATE commands in your slowlog, you can either make the threshold higher, or try to speed up the query execution time, and remember that any aggregation of a wildcard query requires a complete scan of all the documents, and therefore it will be strongly correlated to the index size.

A. Guy
  • 500
  • 1
  • 3
  • 10