gdal icon indicating copy to clipboard operation
gdal copied to clipboard

PostGis layer GetFeatureCount extramly slow

Open wuqi opened this issue 2 years ago • 2 comments

Postgis layer's GetFeatureCount take about 5minutes to get the result

Steps to reproduce the problem.

  1. Open a postgis dataset and table,table include about 2,000,000 features, postgresql's version is 9.6.12

  2. 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

wuqi avatar May 06 '22 03:05 wuqi

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

jratike80 avatar May 06 '22 06:05 jratike80

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 ?

wuqi avatar May 06 '22 07:05 wuqi