Hello all,

I am trying to formulate a query for the group-wise maximum/minimum on a 
single class in OrientDB (was initially working with version 2.1.0 
release). However, I haven't been able to make a reasonable query to do 
it... 

My first attempt looked like:

select max(tx),@rid,name,valid from Test group by name

where the test schema was:

class Test {
  "name" : string,
  "tx" : integer,
  "valid" : boolean
}

However, this didn't work, since OrientDB doesn't return the correct record 
for the @rid and valid fields associated with the max tx field (it doesn't 
work for most other RDBMs either; see Database Journal / SQL Antipatterns 
<http://www.databasejournal.com/features/mysql/article.php/3893756/SQLAntipatterns-Avoiding-the-Pitfalls-of-Database-Programming.htm>,
 
and multiple issues on StackOverflow). I commented on this issue 
<https://github.com/orientechnologies/orientdb/issues/2585> the other day, 
and have actually attempted to modified OrientDB to support this specific 
use case (see commit 56324ec 
<https://github.com/jlowenz/orientdb/commit/56324ec229fd4d0d49af2da4b9f85efcaee9e910>
). 

However, OrientDB doesn't support joins (the solution for the other DBs), 
so after trial and error I formulated the following query:

select * from Test let $parms=(select name,max(tx) from Test where name=
$parent.current.name) where $parms[0].max = tx

but this is REALLY slow (I get why - basically running the LET query for 
every record). I built some test code, and the average time for this query 
is 12 seconds for 1600 records (100 names plus 16 tx values each). In 
contrast, the modified min/max record selection code yields an average 31 
*milliseconds*.

I was wondering if anyone here has a way to do this? It seems like I must 
be missing something obvious, and I'd appreciate any help on this.

BTW - running test in orientdb.core is taking forever in the *develop*
 branch. 

Thanks,
-Jason
 

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to