skip to main content
Querying with OData Version 4 : Formulating queries with OData Version 4 : Query options and optimizing response times : Improving performance when using Count
  

Try Now
Improving performance when using Count
The $count OData system query option includes the count of the number of entities that satisfy a query in the response. The count is included in the first page in server-side paging, and in every page when the client controls paging. Possible values for the parameter include true and false:
inlineCountQueryOp = "$count=" "true" | "false")
Calculating the count for very large collections can take time. The default behavior for Hybrid Data Pipeline differs for relational and cloud data sources:
*For relational data stores, by default, Hybrid Data Pipeline sends a separate query to get the count before requesting the records. This behavior tends to result in a quicker response for the first page of results. However, it requires two queries to be executed rather than one. And, in some data sources, the count(*) aggregate is not efficiently implemented.
*For cloud-based data stores, by default, Hybrid Data Pipeline fetches the entire result before returning the first page. For small results, this approach will always be faster. However, this approach may have longer initial response time for the first page if the result is large.
This behavior can be changed in the data source definition, as described in Configuring data sources for OData Version 4 connectivity or by using the $count parameter. With a value of true, Hybrid Data Pipeline will include the count in the response. For example:
https://<myserver>:<port>/api/odata4/OracleOPTest/Customers?$count=true
With a value of false, Hybrid Data Pipeline avoids obtaining a count and avoiding the associated overhead. For example:
https://<myserver>:<port>/api/odata4/OracleOPTest/Customers?$count=false