When performing a query on the database, accessing a record's ID directly or using a record range allows performance to be significantly sped up by avoiding the table scan which is used when a WHERE clause is included.
However, if a WHERE clause is unavoidable, performance can still be improved by simplifying the portion after the clause as much as possible. As a boolean is the simplest possible datatype, having a boolean field that can be used in a WHERE clause can significantly improve performance compared to a more complex operation.
-- Fill up the database a bit with 10,000 records CREATE |person:10000| SETrandom_data=rand::string(1000) RETURNNONE; -- Add one outlier with short random_data CREATEperson:oneSETrandom_data="HI!"RETURNNONE;
-- Function call + compare operation: slowest SELECT * FROMpersonWHERErandom_data.len() <10; -- Compare operation: much faster SELECT * FROMpersonWHEREdata_length<10; -- Boolean check: even faster SELECT * FROMpersonWHEREis_short; -- Direct record access: almost instantaneous SELECT * FROMperson:one;