Virtuoso slow first response

Hello everybody!

I am using open-source Virtuoso 07.20.3229. I am working with HTTP SPARQL endpoint.

From time to time I encounter the following problem. Sometimes, when I send SPARQL query to my Virtuoso instance for the first time after some period of inactivity, my first query executes for a relatively long time.
For example, for the first time, of one my queries executes agains database for 80 ms while normally their execution time somewhere under 20 ms. However, the subsequent totally different queries(from the first one) work fast as expected.

I have about 270 millions triples in my database. My instance has 32 GB RAM and 4 CPU.

As I have understood these are the most crucial performance params in config file(virtuoso.ini) and they have the following values.

I suppose it has something to do with cache of the database, but that’s all I can think of right now.
Can you please tell what can be the cause of such behavior?

Also, I would be very grateful if can give me links to the inner workings of Virtuoso cache and SPARQL to SQL transformation(I think my problem is tied to these database components).

When you first start Virtuoso and most database they are “cold” ie data has to be loaded directly from slow permanent storage, but once a given query loads the first time the dataset required for servicing the query is loaded in faster RAM “cache”, thus subsequent execution of the query is much faster.

The NumberOfBuffers INI file param specifies the number of 8K memory buffers are allocated by Virtuoso for hosting the database working set in memory as detailed in the Performance Tuning Guide. I would also recommend reading the Virtuoso Performance Diagnostics documentation.

Finally, note Virtuoso also provides functions to save the database working set memory state and reload it on restart start to preload the working set into memory resulting in the database effectively being pre-“warmed” with all previous queries being executed against the cached data in memory on first run, as detailed in the post Controlling the Database Working Set in OpenLink Virtuoso.