Query time too long

Excuse me. After I started the Virtuoso service in my ubuntu system, I use SPARQLWrapper to query it. Here is one example that aims to get the 3-hop relations far away from the starting entity. However, it took too much time to get the results and occur the error of endpoint returned code 500 and response before I set the MaxQueryExecutionTime = 7200 s. Therefore, I want to know is it right for such a long query time for the query and how should I improve the query speed.

PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
PREFIX : http://rdf.freebase.com/ns/
SELECT distinct ?r3
WHERE {
FILTER (?t3 != ?t1)
FILTER (!isLiteral(?t3) OR lang(?t3) = ‘’ OR langMatches(lang(?t3), ‘en’))
“”" ‘:’ + tpe + ’ :’ + r0 + ’ ?t0 .\n’ +
‘?t0’ + ’ :’ + r1 + ’ ?t1 .\n’ +
‘?t1’ + ’ :’ + r2 + ’ ?t2 .\n’ +
‘?t2 ?r3 ?t3 .’ “”"
}
where the tpe, r0, r1, r2 are the specified variables. And I want to get the ?r3 values. The total number of triples in the database is about 140 million.

Here is the virtuoso.ini file:

[Database]

DatabaseFile = /mnt/jiangjinhao/PLM4KBQA/freebase/webqsp_2hop_db/database/virtuoso.db

ErrorLogFile = /mnt/jiangjinhao/PLM4KBQA/freebase/webqsp_2hop_db/database/virtuoso.log

LockFile = /mnt/jiangjinhao/PLM4KBQA/freebase/webqsp_2hop_db/database/virtuoso.lck

TransactionFile = /mnt/jiangjinhao/PLM4KBQA/freebase/webqsp_2hop_db/database/virtuoso.trx

xa_persistent_file = /mnt/jiangjinhao/PLM4KBQA/freebase/webqsp_2hop_db/database/virtuoso.pxa

ErrorLogLevel = 7

FileExtend = 200

MaxCheckpointRemap = 2000

Striping = 0

TempStorage = TempDatabase

[TempDatabase]

DatabaseFile = /mnt/jiangjinhao/PLM4KBQA/freebase/webqsp_2hop_db/database/virtuoso-temp.db

TransactionFile = /mnt/jiangjinhao/PLM4KBQA/freebase/webqsp_2hop_db/database/virtuoso-temp.trx

MaxCheckpointRemap = 2000

Striping = 0

[Parameters]

ServerPort = 13001

LiteMode = 0

DisableUnixSocket = 1

DisableTcpSocket = 0

ServerThreads = 100 ; increased from 20

CheckpointInterval = 60

O_DIRECT = 1 ; increased from 0

CaseMode = 2

MaxStaticCursorRows = 100000

CheckpointAuditTrail = 0

AllowOSCalls = 0

SchedulerInterval = 10

DirsAllowed = .

ThreadCleanupInterval = 0

ThreadThreshold = 10

ResourcesCleanupInterval = 0

FreeTextBatchSize = 100000

PrefixResultNames = 0

RdfFreeTextRulesSize = 100

IndexTreeMaps = 256

MaxMemPoolSize = 200000000

PrefixResultNames = 0

MacSpotlight = 0

IndexTreeMaps = 64

NumberOfBuffers = 9895250.1

MaxDirtyBuffers = 4947625.05

[SPARQL]

ResultSetMaxRows = 50000

MaxQueryCostEstimationTime = 7200 ; in seconds (increased)

MaxQueryExecutionTime = 7200; in seconds (increased)

[HTTPServer]

ServerPort = 3001

Charset = UTF-8

ServerThreads = 100 ; increased from unknown

What SPARQLWrapper are you using ?

What happens if you run the query via the Virtuoso SPARQL endpoint or directly via the Virtuoso isql command line tool (prepending SPARQL keyword for it to run from isql) ?

What does the output of running the status(); command from isql ?

I don’t understand those settings as they whole numbers as indicated in the Virtuoso Performance Tuning documentation ?

Is that the complete virtuoso.ini file you provided, as it looks minimalistic ?