gdal
gdal copied to clipboard
PostGis layer GetFeatureCount extramly slow
Postgis layer's GetFeatureCount take about 5minutes to get the result
Steps to reproduce the problem.
-
Open a postgis dataset and table,table include about 2,000,000 features, postgresql's version is 9.6.12
-
pLayer->GetFeatureCount(); this took about 5 minutes or longer to get the result
Operating system
Windows 10 64bit
GDAL version and provenance
the 3.4.2 c++ version
How long does it take if you run directly from the database SELECT count(*) from my_table
?
See also https://wiki.postgresql.org/wiki/Slow_Counting
How long does it take if you run directly from the database
SELECT count(*) from my_table
? See also https://wiki.postgresql.org/wiki/Slow_Counting
Almost the same time,5 minutes ,I have tried this ,and the : SELECT reltuples::bigint AS estimate FROM pg_class WHERE oid = 'schema_name.table_name'::regclass;
is only 19ms, so can we change the sql in code ?