FeatureSizeFeatureCollection causes unoptimized FeatureCollection.size() calls in WFS requests

Description

By default, WFS requests wrap the underlying feature collection with a FeatureSizeFeatureCollection. FeatureSizeFeatureCollection overrides size(), and iterates over all the underlying features if a negative value is returned from the underlying feature source. Returning -1 is a valid response to getCount() (confirmed here and by Jody in the original PR that added the FeatureSizeFeatureCollection (https://github.com/geoserver/geoserver/pull/1355#issuecomment-263688535). The suggested pattern appears to be:

In GeoMesa, by default return we -1, as counts are expensive for us, but we allow overriding that behavior with a system property or a query hint. We have an optimized method to determine counts when needed, which is much faster than iterating over the entire feature collection, but that is being bypassed here.

As a proposed solution, I would suggest setting the default value for DEFAULT_CACHE_SIZE to 0 in FeatureSizeFeatureCollection. That way, it would be disabled by default, but could easily be enabled by setting the system property.

Environment

None

Status

Assignee

Unassigned

Reporter

Emilio Lahr-Vivaz

Triage

None

Fix versions

Affects versions

2.13.0
2.13.1

Components

Priority

Medium
Configure