Query Performance Issues

9 views
Skip to first unread message

hayden....@gmail.com

unread,
Feb 7, 2017, 10:47:02 AM2/7/17
to Stardog
Hi there,

I'm new to using Stardog and have been playing around with a very small number of triples (<100,000), yet I am still encountering problems with query performance. 
Running this query to return all triples takes about 8 seconds: select * where {?s ?p ?o .}
Running more complex queries causes the server to time out. 
I'm wondering whether the issue might be in my database settings, or perhaps in memory allocation. I have 4 gb of heap and 4 gb of non-heap memory allocated. When I reduce these values to 2 gb, I still have the same problem.
I am using reasoning type EL and sameAs reasoning "Full." Query All Graphs is set to "On." All index settings are set to the default.
Stardog server is running on an AWS instance with 7.5 GB of memory and 4 cores (c4.xlarge).

Another thing: I tried to generate a query plan to determine whether the problem was in my queries, not the software. However when I run "stardog-admin query list -u username" and enter my password in order to get the query ID, it returns "0 queries running," even when I have a query running which has been running for about 10 seconds (so before the timeout hits).


Zachary Whitley

unread,
Feb 7, 2017, 11:00:43 AM2/7/17
to Stardog
Are there any errors or warnings in stardog.log (it will be located in your stardog home dir $STARDOG_HOME)?

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+unsubscribe@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+unsubscribe@clarkparsia.com.

hayden....@gmail.com

unread,
Feb 7, 2017, 11:08:53 AM2/7/17
to Stardog

Thanks for your response. I am getting several warnings related to an imported ontology (obib merged inferred). I've attached a screenshot of the error log.


On Tuesday, 7 February 2017 11:00:43 UTC-5, Zachary Whitley wrote:
Are there any errors or warnings in stardog.log (it will be located in your stardog home dir $STARDOG_HOME)?
On Tue, Feb 7, 2017 at 10:47 AM, hf...@upenn.edu <hayden....@gmail.com> wrote:
Hi there,

I'm new to using Stardog and have been playing around with a very small number of triples (<100,000), yet I am still encountering problems with query performance. 
Running this query to return all triples takes about 8 seconds: select * where {?s ?p ?o .}
Running more complex queries causes the server to time out. 
I'm wondering whether the issue might be in my database settings, or perhaps in memory allocation. I have 4 gb of heap and 4 gb of non-heap memory allocated. When I reduce these values to 2 gb, I still have the same problem.
I am using reasoning type EL and sameAs reasoning "Full." Query All Graphs is set to "On." All index settings are set to the default.
Stardog server is running on an AWS instance with 7.5 GB of memory and 4 cores (c4.xlarge).

Another thing: I tried to generate a query plan to determine whether the problem was in my queries, not the software. However when I run "stardog-admin query list -u username" and enter my password in order to get the query ID, it returns "0 queries running," even when I have a query running which has been running for about 10 seconds (so before the timeout hits).


--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.

hayden....@gmail.com

unread,
Feb 7, 2017, 11:10:36 AM2/7/17
to Stardog, hayden....@gmail.com
I responded from a different account but I am the original poster of the message. Sorry if confusing.

Zachary Whitley

unread,
Feb 7, 2017, 11:13:01 AM2/7/17
to Stardog
Looks like your ontology is outside the EL profile. You can try removing the axioms that are outside EL or choose a more expressive profile that includes those axioms. Someone from Stardog will have to comment on the performance when trying to run with invalid axioms. I don't know if that's expected or not.


For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+unsubscribe@clarkparsia.com.

Håvard Ottestad

unread,
Feb 7, 2017, 11:13:01 AM2/7/17
to Stardog
I've run into this quite a number of times.

Stardog does backwards chaining when reasoning. So if you do a ?s ?p ?o query, it needs to backwards chain everything. This is exceptionally slow.

Returning all data is in general a slow operation, on pretty much any database. 

Try running some other queries, and playing with turning reasoning on and off to see things are fast enough for you.

Stephen Nowell

unread,
Feb 7, 2017, 11:32:13 AM2/7/17
to sta...@clarkparsia.com
Hi,

Zach and Håvard have pretty much nailed the issues. If your ontology is
not valid EL, you can change the reasoning level/type via
stardog.properties [1] when starting the server. If it is large and
deeply nested, then a `select * where {?s ?p ?o}` query is going to be
tremendously intensive to evaluate, especially since Stardog does not
use materialization when performing reasoning, instead using query
rewriting [2].

Changing the reasoning level and (more importantly) making your queries
more specific to get the needed information will very much help with
query execution time.

Cheers,
Stephen

[1] https://docs.stardog.com/#_reasoning_types
[2] https://docs.stardog.com/#_query_rewriting
> --
> -- --
> You received this message because you are subscribed to the C&P
> "Stardog" group.
> To post to this group, send email to sta...@clarkparsia.com
> To unsubscribe from this group, send email to
> stardog+u...@clarkparsia.com

hayden....@gmail.com

unread,
Feb 7, 2017, 11:57:02 AM2/7/17
to Stardog
I could be wrong, but I think the problem I am having is more than poorly formulated queries. I have run several more targeted queries and many of them end up timing out. With such a small amount of data, I did not feel that this should be an issue. Stardog is also not recognizing that any queries are running (from above, when I enter in CLI "stardog-admin query list -u username" and enter my password in order to get the query ID, it returns "0 queries running." 

An example of a non-sensitive targeted query I have run which times out:

select distinct ?code where { 

      ?code a obib:CRID .

      ?code obib:denotes ?person .

      ?person a obib:homoSapien .

      ?subjectEnrollment obib:hasSpecifiedOutput ?person .

       ?subjectEnrollment a obib:humanSubjectEnrollment .

       ?specimenCollection obib:precededBy ?subjectEnrollment .

       ?specimenCollection a obib:specimenCollection .

       ?specimenCollection obib:hasSpecifiedOutput ?bloodSpecimen .

       ?bloodSpecimen a obib:bloodSpecimen .

       ?bloodSpecimen obib:hasPart ?EDTA .

       ?EDTA a obib:EDTA .}


Strangely, this query ran fine a few days ago but now for some reason causes the server to time out, with no changes to the database that I can speak of. 

Thanks for the help from everyone so far.

Stephen Nowell

unread,
Feb 7, 2017, 12:01:40 PM2/7/17
to sta...@clarkparsia.com
Hi,

Can you send us the output of `stardog query explain -r <put query here>`? The Query Plan generated by Stardog should help us figure out where the bottlenecks might be.

Cheers,
Stephen

Zachary Whitley

unread,
Feb 7, 2017, 12:05:25 PM2/7/17
to Stardog
Running fine a few days ago but having trouble now is a little strange. You might want to see if there is anything else on the machine that might be competing for resources.

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---

hayden....@gmail.com

unread,
Feb 7, 2017, 12:25:50 PM2/7/17
to Stardog
Hi Stephen, I'm having trouble running the explain function you suggested. I'm trying to store my query in a stored query, so that I can just put the name of my query into the explain function, using the "stardog-admin stored add -n name 'query'" command, yet I receive the output : Unknown Command Stored. Is this a deprecated feature? If so, is there another way to use a stored query for the purpose I am trying to do so?

Zachary Whitley

unread,
Feb 7, 2017, 12:37:17 PM2/7/17
to Stardog
I don't think you mentioned what version you are running but named queries was added in 4.2


Can you send the exact command that you're having trouble with?

---

hayden....@gmail.com

unread,
Feb 7, 2017, 12:45:10 PM2/7/17
to Stardog
Ah, I'm running 4.1, that explains why stored queries isn't working. 

Tried this command, got error "Illegal character in path at index 28:  http://localhost:8080/select distinct ?crid where {  ?crid a obib:CRID ...

stardog query explain -r -u username "select distinct ?crid where {  ?crid a obib:CRID . ?
crid obib:denotes ?person . ?person a obib:homoSapien . ?subjectEnrollment obib:hasSpecifiedOutput ?person . ?subjectE
nrollment a obib:humanSubjectEnrollment . ?specimenCollection obib:precededBy ?subjectEnrollment . ?specimenCollection
 a obib:specimenCollection . ?specimenCollection obib:hasSpecifiedOutput ?bloodSpecimen . ?bloodSpecimen a obib:bloodS
pecimen . ?bloodSpecimen obib:hasPart ?EDTA . ?EDTA a obib:EDTA .}"

Perhaps the double quote is not the correct demarcation of a query? Also tried with <> and just the text of the query with no surrounding characters, but neither worked.
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.

Zachary Whitley

unread,
Feb 7, 2017, 12:50:29 PM2/7/17
to Stardog
Looks like you forgot to give it the database name right before the query. Double quotes can be ok depending on the query but if you want to be extra careful you can use single quotes.


For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+unsubscribe@clarkparsia.com.

hayden....@gmail.com

unread,
Feb 7, 2017, 1:03:02 PM2/7/17
to Stardog
Yep, that was the problem. Should have caught that one myself.

Sent in that command, now the server is hanging again. I've been waiting about ten minutes, and my shell is stuck after printing "The Query Plan:"

Screenshot

hayden....@gmail.com

unread,
Feb 7, 2017, 1:36:18 PM2/7/17
to Stardog, hayden....@gmail.com

I captured a screenshot from the CPU monitor feature from the Amazon EC2 instance off of which I am running Stardog. The large spike is where I began the Query Plan request, and the drop coincides almost exactly with the time that I killed the request after it failed to produce the query plan.

Stephen Nowell

unread,
Feb 7, 2017, 2:37:29 PM2/7/17
to sta...@clarkparsia.com
Hi Hayden,

I have found what I believe to be the OBIB ontology you are using (https://bioportal.bioontology.org/ontologies/OBIB) but your query doesn't seem to line up with it. You have as a predicate things like `obib:denotes`. However this ontology has no such predicate. Instead it has <http://purl.obolibrary.org/obo/IAO_0000219> which has an rdfs:label of "denotes."

Are you supplementing the ontology with data of your own that make those connections? Am I in the right ballpark ontology-wise? I only ask because I am attempting to recreate your attempt at generating the query plan in hopes of pinning down the issue.

Cheers,
Stephen

hayden....@gmail.com

unread,
Feb 7, 2017, 2:48:42 PM2/7/17
to Stardog
Hi Stephen,
Yes, you are absolutely on the right track; that is the ontology that I am using. I have uploaded a terms file along with the ontology file which makes the connections that you have noticed (it specifies for instance, that IAO_0000219 means "denotes") and I have tested and confirmed that this file works properly with simpler queries.
Very curious to hear the results of your recreation; I currently feel that the most likely cause of the problem is either too many axioms imported in our ontology, or a problem with server memory/resource allocation.

Kendall Clark

unread,
Feb 7, 2017, 2:53:33 PM2/7/17
to sta...@clarkparsia.com
Hayden,

Can you share this with us so we can recreate and debug what you are seeing?

Cheers,
Kendall

hayden....@gmail.com

unread,
Feb 7, 2017, 3:01:15 PM2/7/17
to Stardog
Hi Kendall, I think you are referring to the terms file. I've attached it here. I put this and the ontology file into a named graph which I then designated as my tbox.

I'm not sure if you will need the exact triples that I am using to do the recreation. Unfortunately they contain patient data so I wouldn't be able to distribute those online.
terms.ttl

Stephen Nowell

unread,
Feb 10, 2017, 2:16:22 PM2/10/17
to sta...@clarkparsia.com
Hi Hayden,

Apologies for the delayed response here. We're in the process of moving this mailing list over to community.stardog.com, and this thread escaped me somehow.

I've created a topic for this: https://community.stardog.com/t/query-performance-issues/91

Any further discussion should happen over there. I'll also be posting what we've figured out so far.

Cheers,
Stephen

hayden....@gmail.com

unread,
Feb 14, 2017, 10:59:23 AM2/14/17
to Stardog
Hello, I am responding here due to limits placed on me as a "new user" on the Stardog community page, and the ability to attach files. I've managed to generate a query plan for one of my very slow running queries, and was wondering how I can best interpret this result to improve my query.
case_query_plan_successful.txt

Stephen Nowell

unread,
Feb 14, 2017, 11:16:30 AM2/14/17
to sta...@clarkparsia.com
Hayden,

I have (I think, anyway) altered the settings so that you should be able to attach this to the thread. Best to keep it all in one place :D

Cheers,
Stephen

hayden....@gmail.com

unread,
Feb 14, 2017, 11:20:24 AM2/14/17
to Stardog
I still get an error which says "Sorry, new users cannot post 3 times in the same topic" or something along those lines.
Reply all
Reply to author
Forward
0 new messages