Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Best practices for Redis Query Engine performance

Note:
If you're using Redis Software or Redis Cloud, see the best practices for scalable Redis Query Engine page.

Checklist

Below are some basic steps to ensure good performance of the Redis Query Engine (RQE).

Indexing considerations

General

Query optimization

Validate performance (FT.PROFILE)

You can analyze FT.PROFILE output to gain insights about query execution. The following informational items are available for analysis:

Anti-patterns

When designing and querying indexes in RQE, certain practices can hinder performance, scalability, and maintainability. Below are some common anti-patterns to avoid:

The following examples depict an anti-pattern index schema and query, followed by corrected versions designed for scalability with RQE.

Anti-pattern index schema

The following schema introduces challenges for scalability and performance:

FT.CREATE jsonidx:profiles ON JSON PREFIX 1 profiles: 
          SCHEMA $.tags.* as t NUMERIC SORTABLE 
                 $.firstName as name TEXT 
                 $.location as loc GEO

Issues:

Anti-pattern query

The following query is inefficient and not optimized for vertical scaling:

FT.AGGREGATE jsonidx:profiles '@t:[1299 1299]' LOAD * LIMIT 0 10

Issues:

Improved index schema

Here’s an optimized schema that adheres to best practices for vertical scaling:

FT.CREATE jsonidx:profiles ON JSON PREFIX 1 profiles: 
          SCHEMA $.tags.* as t NUMERIC SORTABLE 
                 $.firstName as name TEXT NOSTEM SORTABLE 
                 $.lastName as lastname TEXT NOSTEM SORTABLE 
                 $.location as loc GEO SORTABLE 
                 $.id as id TAG SORTABLE UNF 
                 $.ver as ver TAG SORTABLE UNF

Improvements:

You might be wondering why $.tags.* as t NUMERIC SORTABLE is acceptable in the improved schema and it wasn't previously. The inclusion of $.tags.* is acceptable when:

Improved query

The following query is better suited for vertical scaling:

FT.AGGREGATE jsonidx:profiles '@t:[1299 1299]' 
                LOAD 6 id t name lastname loc ver 
                LIMIT 0 10
                DIALECT 2

Improvements:

RATE THIS PAGE
Back to top ↑