Uploaded image for project: 'GeoServer'
  1. GEOS-8790

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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 2.13.0, 2.13.1
    • Fix Version/s: 2.13.2, 2.14-RC
    • Component/s: WFS
    • Labels:
      None

      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:

      int count = featureSource.getCount();
      if ( count == -1 ) {
        count = featureSource.getFeatures( "typeName").size();
      }
      

      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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              elahrvivaz Emilio Lahr-Vivaz
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: