Check all named graphs

Is there a quick way to check for all named graphs in a db?

We are running a "select distinct ?g where {graph ?g {?s <specific_low_use_predicate> ?o}}" but performance is still over a minute. (We have about 150 named graphs.)

Any suggestions would be appreciated.


Hi Andrea,

select ?g { graph ?g {} }

should work with a recent version of Stardog.



select distinct ?g
where {
graph ?g {}

Pavel, I did try that as well. It was a BIT faster at 56 secs (not greater than 1 min) but still that is kind of bad (IMHO).


It is bad indeed and strongly suggests db optimize is needed (unless your named graphs aren't added/deleted, in which case we need to investigate what's going on).


Now that you say that ... we are testing some new software and named graphs come and go.

Might the lack of optimization also account for high memory usage?

Can optimize run while the db is in use or does it have to quiesced?


It's possible. Lots of data writes without db optimize likely means the data is scattered over a large number of files. Reading those files during query evaluation will consume more memory than if the data layout was optimal.

But the biggest factor here is that reads get slower as they have to i) read more files, ii) skip over deleted data.

Yes, db optimize runs transparently to concurrent operations.


I will try that and report back.

Thank you so much for the insights.


Yup, I am an idiot. Your suggestion helped a lot for performance of the distinct ?g query.

However, my server memory is still being consumed at a dangerous rate.

Any other suggestions will be tested immediately :-).


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.