Solutions

MarkLogic Data Hub Service

Fast data integration + improved data governance and security, with no infrastructure to buy or manage.

Learn More

Learn

Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up

Community

Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up

Company

Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up

 
Knowledgebase:
XQuery Parsing / Linking Explained
19 March 2015 07:26 PM

Introduction

The first time a query is executed, it will take longer to execute than subsequent runs.  This extra time for the first runs become more pronounced when importing large libraries.  Why is this so and is there anything that we can do to improve the performance?

Details

When MarkLogic evaluates an XQuery script it first compiles it into a complete XQuery program. When compiling the program, the transitive closure of all imported modules are linked together and all function and variables names are resolved.

MarkLogic maintains a cache of pre-parsed library modules, so library modules are not re-parsed when a program is compiled. But every unique program needs to be globally linked together with all its included library modules before it is executed. The time for this linking can result in "First Runs" being slower than subsequent runs.

Performance recommendation

When using library modules, you will likely see better performance if you parameterize frequently used queries through variables and not through code. For example, use external variables in xdbc requests, or use request fields with application server requests. 

(0 vote(s))
Helpful
Not helpful

Comments (0)