Performance of SOLRQL vs XWQL

Last modified by Vincent Massol on 2025/02/12 12:25

cogSimple benchmark to compare performance of execution a query with SOLR vs XWQL
Type
Category
Developed by

Vincent Massol

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

XObject

Simple list of all documents having a given xobject.

{{groovy}}
def benchmark = { closure ->  
  start = System.currentTimeMillis()  
  closure.call()  
  now = System.currentTimeMillis()  
  now - start  
}

def duration1 = benchmark {  
def queryStatement = 'object:XWiki.UIExtensionClass'
def query = services.query.createQuery(queryStatement, 'solr')
query.bindValue('fq', 'type:DOCUMENT')
query.setLimit(500).setOffset(0)
def searchResponse = query.execute()[0]
searchResponse.results.each() {
  println "* ${it.fullname}"
}
}  
println ''
println ''
println ''  
  
def duration2 = benchmark {  
def results = services.query.xwql('from doc.object(XWiki.UIExtensionClass) as uix').execute()
results.each() {
  println "* ${it}"
}
}
  
println ''
println ''
println ''  

println "execution took ${duration1} ms"  
println "execution took ${duration2} ms"  
{{/groovy}}

Result

Results on XWiki 10.1 shows a x2 to x4 performance gain in favor of XWQL.

For an order of magnitude, execution times are in the order the 2-10ms when I executed this locally on my machine.

XProperty LIKE

Simple list of all pages having a given XObject and the value of an XProperty of that XObject being a given value with a wildcard (LIKE).

{{groovy}}
def benchmark = { closure ->  
  start = System.currentTimeMillis()  
  closure.call()  
  now = System.currentTimeMillis()  
  now - start  
}

def duration2 = benchmark {  
def results = services.query.xwql("where doc.object(XWiki.UIExtensionClass).extensionPointId LIKE 'org.xwiki.platform%'").execute()
println "Count: ${results.size()}"  
results.each() {
  println "* ${it}"
}
}

println ''
println ''
println ''  
    
def duration1 = benchmark {  
def queryStatement = 'object:XWiki.UIExtensionClass AND property.XWiki.UIExtensionClass.extensionPointId:org.xwiki.platform*'
def query = services.query.createQuery(queryStatement, 'solr')
query.bindValue('fq', 'type:DOCUMENT')
query.setLimit(500).setOffset(0)
def searchResponse = query.execute()[0]
println "Count: ${searchResponse.results.size()}"  
searchResponse.results.each() {
  println "* ${it.fullname}"
}
}  
  
println ''
println ''
println ''  

  
println "SOLRQL execution took ${duration1} ms"  
println "XWQL execution took ${duration2} ms"  
{{/groovy}}

Results

Results on XWiki 10.1 shows a x2 to x5 performance gain in favor of XWQL.

For an order of magnitude, execution times are in the order the 2-14ms when I executed this locally on my machine.

Get Connected