What does `SlowLog` in `RedisSearch` depends on?

151 Views Asked by At

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?

1

There are 1 best solutions below

0
A. Guy On

The SLOWLOG log records all queries and commands that took more than slowlog-log-slower-than μs threshold, which is 10 ms by default. You can set the threshold to some larger value to catch only very slow executions. See the "SLOW LOG" section in the redis.conf file.

The query you included might be simple, but it requires you to scan the entire document table in your index. In addition, if you didn’t mark the @RoomId and @Price fields as SORTABLEs, it also requires loading 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 this 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 the 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. Therefore it will be strongly correlated to the index size.