Slow WFS json response because of totalFeatures from large Postgres table

Description

Related issue reported as a bug: https://osgeo-org.atlassian.net/browse/GEOS-7239

Related commit causing the problem:

https://github.com/geoserver/geoserver/commit/d89885e9408c097120cb6df0e910fdf315f9a229#diff-1b4d0a8e0a53aad5084a306768223d80

This commit has caused an issue with Postgres database because fetching totalFeatures making the request very slow. Postgres fetches count going through all the rows in the table and index helps with vacuum analyze but still, it's not optimal enough and randomly slows down count query. This should have been a format_options (or something else) if you want totalfeatures or not? In my case the postgres was taking 1 minute to get the count of rows (table with 8 million rows with unique index). After vacuum analyze it took ~4 seconds but still without this totalFeatures the geoserver WFS request takes 0.25 milliseconds.

Totalfeatures is not a standard geojson attribute. Nobody looked into this request in last 3 years. I am still struggling and holding back using geoserver 2.2.5 version.

Environment

None

Assignee

Unassigned

Reporter

SSA

Triage

None

Fix versions

None

Affects versions

Components

Priority

Medium
Configure