Search code examples
regexdatabase-performancesql-likegraph-databasesorientdb

Why OrientDB doesn't use indexes for searching with "LIKE" operator?


I found that OrientDB is too slow (at least much slower than Neo4j) even on relatively small (150K) datasets when searching records by text pattern despite the presence of indices.

For example I have both UNIQUE and FULLTEXT indexes for the "username" property but as show below OrientDB doesn't use any.

orientdb> explain select username from P where username like 'log%'    

Profiled command '{current:#10:152060,documentReads:152061,documentAnalyzedCompatibleClass:152061,recordReads:152061,elapsed:6.5357623,resultType:collection,resultSize:88}' in 6,537000 sec(s):
{
  "@type": "d", "@version": 0, 
  "current": "#10:152060", 
  "documentReads": 152061, 
  "documentAnalyzedCompatibleClass": 152061, 
  "recordReads": 152061, 
  "elapsed": 6.5357623, 
  "resultType": "collection", 
  "resultSize": 88, 
  "@fieldTypes": "documentReads=l,documentAnalyzedCompatibleClass=l,recordReads=l,elapsed=f"
}

It there any way to speed up pattern search in OrientDB?


Solution

  • In order to use the full-text index you should use the containstext operator, like:

    explain select username from P where username containstext 'log'
    

    or try this one:

     explain select username from P where username >= 'log' and username < 'loh'