In depth understanding of query performance

Hi, I am a researcher and I am trying to study the underlying query performance of virtuoso queries.

In particular, given a SPARQL query I would like to understand how many triples it reads,
how many pages are read from disk and how many cache misses, and so on.

For example, we seen some queries that when run the first time they are slow and the second time they are faster, but some other queries this is not true, we cannot understand why.

This will help me understand why some query plans are less efficient than others for example.

Is it possible to obtain these statistics?

Details are available on how to create Virtuoso query compilation reports from the SPARQL endpoint and also how to obtain query explain and profile plans for SPARQL queries from the Virtuoso isql command line tool. With documentation on how to analyse query plans available and should serve as a starting point.

Virtuoso query logging can also be used to obtain a large number of execution statistics as well as the full query text and execution plan with per-operator timing and cardinality information.

Other useful links are:

Thanks a lot for the detailed answer!