Learn XQuery |
Home:Learn XQuery:XQuery Tutorial:Performance Tips:Query Pooling Query PoolingPrepared expressions let the programmer decide when a query should be prepared and when a prepared query is no longer needed. In programs that use hundreds or thousands of queries, it is generally better to let DataDirect XQuery® keep track of which queries are actually being used, preparing them the first time they are executed, and discarding the least frequently used prepared queries if there are too many queries. This is called query pooling. In DataDirect XQuery®, you enable query pooling by specifying the number of prepared queries to hold in the pool. If you configure your connection by setting properties in the Java API, you can set the MaxPooledQueries property to do this; for instance, the following code sets the size of the query pool to 20: Example 4. Enabling Query Pooling with the Java API
XQDataSource dataSource = new DDXQDataSource();
dataSource.setJdbcUrl("jdbc:xquery:sqlserver://server1:1433;databaseName=stocks");
dataSource.setMaxPooledQueries(20);
XQConnection connection = dataSource.getConnection();
If you configure your connection using a Source Configuration File, you can set the size of the query pool using the maxPooledQueries element: Example 5. Enabling Query Pooling in a Source Configuration File
<?xml version="1.0" encoding="UTF-8"?>
<XQJConnection xmlns="http://www.datadirect.com/xquery">
<maxPooledQueries>20</maxPooledQueries>
<JDBCConnection name="stocks">
<url>jdbc:xquery:sqlserver://localhost:1433</url>
<sqlxmlMapping>
<forest>true</forest>
<identifierEscaping>none</identifierEscaping>
</sqlxmlMapping>
</JDBCConnection>
</XQJConnection>
|
Try DataDirect XQuery® Free!Put the power, scalability, and performance of DataDirect XQuery® to work for you today! Our free trial lets you see for yourself how easy it is to build data integration applications that access relational, EDI, and other file formats as XML! Online Video Tutorials!Our easy-to-follow online video tutorials are a great way to get acquainted with the many features of DataDirect XQuery®. And if you like what you see, download a free copy today and try DataDirect XQuery® for yourself! Back to School with DataDirect XQuery®Getting your mind around the possibilities of a data integration technology as promising as XQuery can be difficult, but our XML developers Webinars will help you understand the power and versatility of XQuery, and our favorite XQuery processor, DataDirect XQuery®. |





