[Tile-serving] [openstreetmap/osm2pgsql] Flex backend creates two indices on way table (#1312)

Kevin B Kenny notifications at github.com
Sat Nov 7 18:50:42 UTC 2020


I'm trying to use the `flex` backend to create a table having one row for each member of each route relation (with certain filters applied). (I realize that this layout may be inefficient; I'm working according to the principle of 'make it correct before you make it fast.')

I started from the project's [compatible.lua](https://github.com/openstreetmap/osm2pgsql/blob/master/flex-config/compatible.lua) script, and added code to create the table in question.

When I looked at the table in `psql` afterwards, I was rather surprised to see:
```
kennykb at kenny-server-3:/storage/kennykb/Maps/OSM-US-CT$ psql -d gis
psql (12.4 (Ubuntu 12.4-0ubuntu0.20.04.1))
Type "help" for help.

gis=> \d+ us_ct_osm_shieldway
                            Table "public.us_ct_osm_shieldway"
 Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
--------+---------+-----------+----------+---------+----------+--------------+-------------
 wayid  | bigint  |           | not null |         | plain    |              | 
 idx    | integer |           |          |         | plain    |              | 
 relid  | bigint  |           |          |         | plain    |              | 
 role   | text    |           |          |         | extended |              | 
Indexes:
    "us_ct_osm_shieldway_wayid_idx" btree (wayid)
    "us_ct_osm_shieldway_wayid_idx1" btree (wayid)
Access method: heap
``` 

Note the presence of two identical indices on us_ct_osm_shieldway(wayid_idx). The second index is useless and will result in needless overhead on queries and (especially) updates.

Am I doing something wrong that causes the redundant index, or is this a bug in two-phase processing?

Workaround:

Delete the redundant index after the import.

Platform:
```
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.1 LTS
Release:	20.04
Codename:	focal
```
Version:
```
$ osm2pgsql --version
osm2pgsql version 1.3.0 (1.3.0)

Compiled using the following library versions:
Libosmium 2.15.6
Lua 5.3.3
```

Command used:
```
$ osm2pgsql --create \
	  --prefix=us_ct_osm \
	  --slim \
	  --cache=14000 \
	  --database=gis \
	  --number-processes 3 \
	  --input-reader=pbf \
	  --output=flex \
	  --style=./test2.lua \
	  connecticut-latest.osm.pbf

```
Input file was a recent [Geofabrik export of Connecticut](https://download.geofabrik.de/north-america/us/connecticut-latest.osm.pbf)

Style file is attached.

[style.zip](https://github.com/openstreetmap/osm2pgsql/files/5505267/style.zip)


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/issues/1312
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20201107/b564e7b9/attachment.htm>


More information about the Tile-serving mailing list