TransWikia.com

Unexpected performance for OpenFileGDB driver compared with PostGIS

Geographic Information Systems Asked by giser on January 29, 2021

I am using GeoTools with OGR plugin to read .gdb data, and I found that the performance is rather horrible:

Test code:

    public static void main(String[] args) throws MalformedURLException {
        String gdb = "/data/x.gdb";

        Map<String, Object> params = new HashMap<>();
        //geotools pg
        params.clear();
        params = new HashMap<>();
        params.put("dbtype", "postgis");
        //other connection string omitted

        //ogr gdb
//        params.clear();
//        params.put("DriverName", "OpenFileGDB");
//        params.put("DatasourceName", new File(gdb).getAbsolutePath());

        try {
            long start = System.nanoTime();
            DataStore dataStore = DataStoreFinder.getDataStore(params);
            SimpleFeatureSource sfs = dataStore.getFeatureSource("Water");
            System.out.println("total count " + sfs.getCount(Query.ALL));
            FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
            ReferencedEnvelope bbox = new ReferencedEnvelope(x1,x2,y1,y2, sfs.getSchema().getCoordinateReferenceSystem());
            Filter bboxFilter = ff.bbox(ff.property(sfs.getSchema().getGeometryDescriptor().getLocalName()), bbox);
            Query query = new Query();
            query.setFilter(ff.and(Arrays.asList(bboxFilter)));

            System.out.println("filter count " + sfs.getCount(query));

            long end = System.nanoTime();
            long used = end - start;
            System.out.println("used:" + TimeUnit.NANOSECONDS.toMillis(used) + " ms");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

The test result for OpenFileGDB driver:

total count 821328
filter count 1803
used:11710 ms

Then I exported that data to PG, and got the following result:

total count 821328
filter count 1805
used:1259 ms

PostGIS is much, much better than OpenFileGDB.

Did I miss anything?

2 Answers

It is hard to give an objective answer. Generally speaking OpenFileGDB driver's main purpose is to help GIS users make data accessible without need of proprietary software - read only. In other words fix accessibility problem. OpenFileGDB driver was created by reverse-engineering, and so might not / does not have some functionalities as good as native proprietary driver (which is dependent on third party libraries).

So I believe comparing it with PostGIS at something which was not it's goal is not the best idea. If you are interested in more detail, you can find more informations on official gdal website:

https://gdal.org/drivers/vector/openfilegdb.html

Answered by Miro on January 29, 2021

Finally, I found the answer.

Why it cost too long is that the GDAL(3.1.2) used for test does not support spatial index at all.

Since the docs said:

Since GDAL 3.2, the driver can use the native .spx spatial indices for spatial filtering.

Why I did not notice the version was that I thought the 3.2.x would be the current stable version since the docs mentioned this. So when I downloaded the binary from GISInternal I did not pay much attention to the version number espacially when the PATCH version is 2. Stupid mistake. :(

Then I tried the 3.2.0dev version, the same test cost 80ms instead.

Answered by giser on January 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP