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?
The
SLOWLOGlog records all queries and commands that took more thanslowlog-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 theredis.conffile.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
@RoomIdand@Pricefields asSORTABLEs, it also requires loading the values from the redis key space for every document. From the docs:You can read more about the
SORTABLEfields here.In conclusion, if you wish to not see the
FT.AGGREGATEcommands 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.