readable query is slow, fast query is un-readable

40 views
Skip to first unread message

hartmut bischoff

unread,
Sep 19, 2016, 2:39:31 PM9/19/16
to OrientDB
Hi,  
in a previous mail, I attached a test-database with 
  • a timegraph 'jahr', 'monat' 'tag' 
  • a class 'bar'
  • edges with a property "asset" pointing to a record in a class 'contract'
There is also some inherence : ohcl<- price <- midpoint, volatility  and so on.

The Idea is, to define ranges at the timegraph and investigate the properties of the connected vertices, which belong to some asset.

This is the basic graph

tag -- (out) -- ohlc -- (in) -- bar

In order to query for all data present for a contract (#58:2), 
My first attempt was a  simple direct query:

select expand(out('ohlc')) from tag where out('ohlc).asset = #58:2

unfortunately, an empty set was returned

However, changing to 

select expand(out('ohlc')) from tag where out_midpoint.asset = #58:2

leads to the correct result. 

Question: Is it possible to query inherent edges in this way?


I was very surprised: The query took 0.5 sec, with just a few records in the database.

The query took so long, because the hole time-graph was examined, as explain revealed: documentReads: 55152 

After some thinking, I came out with 

select expand(out('ohlc')) from (select expand(out) from ohlc where asset= #58:2 )

which fetches an identical result but is almost un-readable.  It is 10 times faster: 0,068 sec. 

My question is: Is it possible to write a human readable query without loosing to much performance? I couldn't figure out a solution using the match statement, so maybe there is another solution.  

A last thing: How can I determine the effects of scaling in terms of the execution time of the query. I wonder, whether my query will be as slow, if some hundred contracts and some million bars are present in the database, whereas the first attempt has probably a static execution time.

Thanks in advance

hartmut

Luca Garulli

unread,
Sep 19, 2016, 3:21:51 PM9/19/16
to OrientDB
Have you tried with: 

select expand(out().out('ohlc')) from ohlc where asset= #58:2

Best Regards,

Luca Garulli
Founder & CEO

Want to share your opinion about OrientDB?
Rate & review us at Gartner's Software Review


--

---
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages