Hi, what version of OrientDB are you using? We had two issues related to OR operators and index usage:
https://github.com/orientechnologies/orientdb/issues/2898 https://github.com/orientechnologies/orientdb/issues/2893 and we fixed them some days ago. Could you try again on latest SNAPSHOT? thanks Luigi 2014-10-20 19:53 GMT+02:00 Kanak Agarwal <agarwal.ka...@gmail.com>: > Hello > > My V class contains two properties prop1 and prop2 both of which are > indexed using non unique hash index. > The queries on prop1 alone (select from V where prop1 = 'xyz') or prop2 > alone (select from V where prop1 = 'abc') use the index and perform well. > On the other hand, a query that uses OR in the WHERE clause (select from V > where prop1 = 'xyz' OR prop2 = abc') is very slow - it's not using index > and seems to be doing linear scan. > Any suggestions on how to optimize this query. > > > Here are the SQL explain results > - prop1 query (select from V where prop1 = 'xyz') > > > [{"@type":"d","limit":-1,"compositeIndexUsed":1,"involvedIndexes":["V.prop1"],"fullySortedByIndex":false,"indexIsUsedInOrderBy":false,"current":"#9:20000","evaluated":20,"fetchingFromTargetElapsed":0,"documentReads":20,"documentAnalyzedCompatibleClass":20,"recordReads":20,"elapsed":0.216,"resultType":"collection","resultSize":20,"@rid":"#-1:-1"}] > > - prop2 query (select from V where prop2 = 'abc') > > > [{"@type":"d","limit":-1,"compositeIndexUsed":1,"involvedIndexes":["V.prop2"],"fullySortedByIndex":false,"indexIsUsedInOrderBy":false,"current":"#9:20025","evaluated":20,"fetchingFromTargetElapsed":0,"documentReads":20,"documentAnalyzedCompatibleClass":20,"recordReads":20,"elapsed":0.208,"resultType":"collection","resultSize":20,"@rid":"#-1:-1"}] > > - prop1 or prop2 query (select from V where prop1 = 'xyz' or prop2 = 'abc') > > > [{"@type":"d","current":"#9:39999","evaluated":40000,"fetchingFromTargetElapsed":249,"documentReads":40000,"documentAnalyzedCompatibleClass":40000,"recordReads":40000,"elapsed":249.68301,"resultType":"collection","resultSize":40,"@rid":"#-1:-1"}] > > -- > > --- > You received this message because you are subscribed to the Google Groups > "OrientDB" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to orient-database+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.