Wykres commitów

133 Commity (master)

Autor SHA1 Wiadomość Data
Frédéric Rodrigo 36b7533d3b
Add timers to trigger function (#1006)
Add timer to all trigger refresh functions to help point where the time is spend on update.
2020-10-08 16:57:16 +03:00
Frédéric Rodrigo 8bb77b67a1
Diff update osm transportation name network linestring (#996)
Replacing materialized view by a tables with update from trigger on change only.

Differential update of `osm_transportation_name_linestring`, `osm_transportation_name_linestring` and `osm_transportation_name_linestring_genX`).

At the end of the transaction the dependent rows are updated.

The goal is to update more quickly the content of derivated tables by just updating the changing content. It replaces the update of materialized view because their need a full recompute (with lock issue).

It is the last part of the replacement of materialized view for the transportation layer.

It addresses #814 and a part of #809.
2020-09-28 15:56:10 +03:00
Frédéric Rodrigo 47cdfc2c8b
Move where condition from osm_transportation_name_linestring to materialized view osm_transportation_name_network (fix) (#993)
On PR #991 the differential update was not updated like the main code.

Make similar change to the update code.
2020-09-23 11:10:59 +03:00
zstadler 45f5b53c9c
Stitch `transportation_name` by all language tags (#989)
When OSM roads in the `transportation_name` layer are stitched together, their grouping does not consider all `name:*` tags.
As a result, roads with different `name:*` tags may be stitched together.

The `waterway` layer performs the grouping properly, for the same purpose:
1685eaccbd/layers/waterway/update_important_waterway.sql (L34)

Co-authored-by: Frédéric Rodrigo <fred.rodrigo@gmail.com>
2020-09-21 12:38:13 +03:00
Frédéric Rodrigo 5c640daf4f
Move where condition from osm_transportation_name_linestring to materialized view osm_transportation_name_network (#991)
Reduce the size of the materialized view osm_transportation_name_network by moving the weare clause.
osm_transportation_name_network is only used for osm_transportation_name_linestring.

Co-authored-by: zstadler <zeev.stadler@gmail.com>
2020-09-21 10:02:20 +03:00
Frédéric Rodrigo 550b1f8f90
Replace materialized view osm_transportation_name_network by a table with diff update (#987)
Replacing materialized view by a tables with update from trigger on change only.

The osm_id of object changing on table osm_route_member and osm_highway_linestring are logged.
At the end of the transaction the dependent row of osm_transportation_name_network are updated.

The goal is to update more quickly the content of derivated tables by just updating the changing content. It replaces the update of materialized view because their need a full recompute (with lock issue).

Note, it is only a part of the materialized view of the transportation layer, I am also working on the other parts, other parts are in #892 (omaterialized view on sm_transportation_name_linestring and osm_transportation_name_linestring_genX).

It addresses #814 and a part of #809.
2020-09-18 16:49:55 +03:00
Frédéric Rodrigo df56b75719
Clean update_route_member.sql (#981)
Clean and do refactoring on `update_route_member.sql` as first step to replace materialized view osm_transportation_name_network by tables with diff update. See #892.
2020-09-14 19:13:32 +03:00
Frédéric Rodrigo 9bb17792a6
Remove alignment of AS in SQL and few others (#932)
* Remove alignment of AS in SQL

* Remove alignment of CREATE TABLE in SQL
2020-07-22 13:48:25 +02:00
Yuri Astrakhan 2b95d1cffa
Fix & optimize incorrect function declarations (#918)
* All functions that access database must be declared as `STABLE`, not `IMMUTABLE` -- because database can change at any moment, e.g. during an update
* there are a few functions that could be made `STRICT` -- passing `NULL` as a parameter will always result in a `NULL`, but for some reason that causes a significant decrease in perf.
* tagged one function as parallel safe

NOTE: somehow `ST_AsMVT()` method of tile generation is showing 70-90% slowdown with this patch. I am not sure of why this is happening. If the reason is the `IMMUTABLE` -> `STABLE` change, we may have to dig deeper into PG optimization
2020-06-17 12:15:26 -04:00
Yuri Astrakhan 6457419e0d
NOOP: Format all layer's SQL code (#917)
I would like to reformat all of our SQL to have a concise coding style.
This makes it far easier to understand the code for a casual contributor,
and lets us spot errors more easily.

Most importantly, it makes it much easier to grep (search) the code because it is more likely to be in the same syntax

Some key changes:
* SQL keywords are always UPPERCASE, e.g. `SELECT WHEN AS END ...`
* types, variables, aliases, and field names (identifiers) are always lower case
* `LANGUAGE 'plpgsql'` is now `LANGUAGE plpgsql` (no quotes)
* a few minor spacing/semicolon cleanups

P.S. Per @TomPohys request, `TABLE` is spelled using upper case despite being a type for consistency with PG Docs. Same for `LANGUAGE SQL` vs `LANGUAGE plpgsql`.
2020-06-08 12:19:55 -04:00
Frédéric Rodrigo 2622c5bfac
Update route member tagging support of Trans-Canada Highway (#864)
* Fix space at start in update_osm_route_member()

* Update Canada network route name

* Update Canadian route network
2020-05-22 15:52:51 +02:00
Frédéric Rodrigo dcee493da6
Simplify update_gbr_route_members() (#870)
Code cleaning.

The function `update_gbr_route_members()` use two sub queries, but only one is relay needed.
2020-05-15 11:24:57 -04:00
Yuri Astrakhan 0683185717
Add `requires` to 2 layer definitions (#797)
Mark waterway and transoprtation_name as having a dependency on another layer.
This is currently an unused parameter, but tools will use it later for faster
sql code generation.

Closes #796
2020-04-21 12:36:44 -04:00
Jorge Sanz ace759590e
Parallel capability to layer functions (#728)
This PR allows queries to be parallelized on recent versions of Postgres. The `PARALLEL SAFE` modifier has been added to the layer functions and a PLPGSQL function to convert strings into number has been replaced.

`PARALLEL SAFE` is a modifier for `CREATE FUNCTION` available since Postgres 9.6, so this change does not break current OpenMapTiles supported database version. More details about this topic [here](https://www.postgresql.org/docs/current/parallel-safety.html) and at the reference documentation for [`CREATE FUNCTION`](https://www.postgresql.org/docs/current/sql-createfunction.html).

### Testing procedure

The procedure to test this was:

* Imported `spain.pbf` in a clean environment
* Dumped the OpenMapTiles database from the Postgres Docker image
* Created a clean Postgres 12 database using the default Docker image
* Installed `postgis` 3 from the default Debian package and `osml10n` 2.5.8 from the repository (`make`, etc.)
* Restored the dump
* Lowered the postgres planner parameters for triggering parallel plans:
```sql
set parallel_setup_cost = 5;
set parallel_tuple_cost = 0.005;
```
* Manually added the `PARALLEL SAFE` modifier to each function involved in layer queries (not on updates or inserting functions).
* For each layer, run a testing query to confirm parallel workers were created, something like this:
```sql
explain analyze 
select * from layer_aerodrome_label(tilebbox(8,128,95),10,null)
union all
select * from layer_aerodrome_label(tilebbox(8,128,97),10,null);
```
* After all the layers were processed and confirmed to start parallel executions, a more complete example was run. This example just retrieves the geometries for all the layers from the same tile but without using any MVT related function.

<details><summary>Testing query</summary>

```sql
-- Using the function layer_landuse
explain analyze 
select geometry from layer_water(tilebbox(14,8020,6178),14)
union all
select geometry from layer_waterway(tilebbox(14,8020,6178),14)
union all
select geometry from layer_landcover(tilebbox(14,8020,6178),14)
union all
select geometry from layer_landuse(tilebbox(14,8020,6178),14)
union all
select geometry from layer_mountain_peak(tilebbox(14,8020,6178),14)
union all
select geometry from layer_park(tilebbox(14,8020,6178),14)
union all
select geometry from layer_boundary(tilebbox(14,8020,6178),14)
union all
select geometry from layer_aeroway(tilebbox(14,8020,6178),14)
union all
select geometry from layer_transportation(tilebbox(14,8020,6178),14)
union all
select geometry from layer_building(tilebbox(14,8020,6178),14)
union all
select geometry from layer_water_name(tilebbox(14,8020,6178),14)
union all
select geometry from layer_transportation_name(tilebbox(14,8020,6178),14)
union all
select geometry from layer_place(tilebbox(14,8020,6178),14)
union all
select geometry from layer_housenumber(tilebbox(14,8020,6178),14)
union all
select geometry from layer_poi(tilebbox(14,8020,6178),14)
union all
select geometry from layer_aerodrome_label(tilebbox(14,8020,6178),14);
```
</details>

You can inspect the execution plan and results on [this page](https://explain.dalibo.com/plan/3z). Also [attaching](https://github.com/openmaptiles/openmaptiles/files/3951822/explain-tile-simple.tar.gz) the query and JSON output for future reference. The website gives a ton of details, but you may want to search for nodes mentioning `workers` or `parallel` like in this area referring to `osm_border` or `osm_aeroway_linestring` entities

![image](https://user-images.githubusercontent.com/188264/70647153-9cac9300-1c48-11ea-96ea-ac7a1e2f4a79.png)

### Next steps

Since the execution plan is not showing a parallel append at the top level, meaning it's not running each layer individually, I want to continue experimenting with parameters and queries to see if it's possible to even parallelize more the request.

I will post my finding here, even no change in the code should happen.


cc. @nyurik

Co-authored-by: Yuri Astrakhan <yuriastrakhan@gmail.com>
2020-01-31 19:36:02 -05:00
Yuri Astrakhan 9d6dbfc64f
Use one pass docs image generation (#751)
quicker and cleaner diagram image generation.
Remove etl-graph and mapping-graph targets - redundant

Also, the obsolete "fields" is still in Imposm's code and both names are accepted,
but "fields" is not documented anywhere (PR submitted), and could be removed at any moment.

Our docs were not supporting it until this PR, so renaming it at the same time.

Several images have been updated due to a more inclusive mapping scan
Requires https://github.com/openmaptiles/openmaptiles-tools/pull/147 (merged)
2020-01-22 21:55:22 -05:00
Yuri Astrakhan c9e7ad90c6
Remove unneeded "else null" in conditions (#732)
Minor code cleanup:
SQL already returns NULL in the "WHEN" condition
if it is not matched by any of the cases.

Co-authored-by: Eva Jelinkova <evka.jelinkova@gmail.com>
2020-01-22 17:24:28 -05:00
Yuri Astrakhan 1d91b9ef6e
Noop: tag sql MAT VIEWS with a special comment (#733)
Tag all SQL materialized views with a machine-readable comment
to indicate that this materialized view can be created without
data:

   /* DELAY_MATERIALIZED_VIEW_CREATION */

In the next version of tools this comment can be optionally
replaced with the "WITH NO DATA" parameter, thus allowing
a much faster execution of the SQL script. All materialized
viewes will be populated with data in parallel afterwards
using the `refresh-views` tools script.
2020-01-20 12:02:49 -05:00
golubev fd120ff8ca layers/transportation_name/mapping_diagram.png: update the diagram 2019-11-04 14:25:11 +02:00
Eva Jelinkova dff9a850a6
Merge pull request #675 from Sophox/nyurik-patch-1
Fix err in transportation update_gbr_route_members
2019-10-31 22:46:37 +01:00
Eva Jelinkova c5b58057cb
Merge pull request #677 from lun/321-highway-construction
Add roads under construction
2019-10-31 18:42:11 +01:00
Yuri Astrakhan 0374d4d047 insert non-null osm_id 2019-10-28 12:35:08 -04:00
Yuri Astrakhan 479914e4b5 Fix err in transportation update_gbr_route_members
The query was producing 3 columns - `(member, ref, network)`,
whereas osm_id is a required field (otherwise it throws null constraint).
2019-10-28 12:35:08 -04:00
Yuri Astrakhan eca13f9bed
Refreshed all diagrams, fixed automation & 2 broken graphs (#692)
Seems like etl and mapping diagrams have been neglected
for a long time. Now it regenerates the files and places
them in the source dir.

This PR also fixes two broken files:
* layers/aerodrome_label/mapping_diagram.png
* layers/housenumber/mapping_diagram.png

They were generated using the newest tools version with the fix
https://github.com/openmaptiles/openmaptiles-tools/pull/65
2019-10-26 21:28:43 -04:00
golubev e74bfb67b4 update transportation layers doc (#321) 2019-10-04 15:19:56 +03:00
golubev 73307a610b layers/transportation_name/: add roads under construction, fix SQL error (#321) 2019-10-04 14:50:05 +03:00
jirik 92a056ab78 Abbreviate also name:latin of streets 2018-11-30 15:32:26 +01:00
jirik bae5f21bb4 Respect current grouping of osm_transportation_name_network 2018-11-07 11:08:06 +01:00
Joakim Kronqvist 7ec9e49a44 Only group transportation name based on language tags 2018-11-07 11:08:06 +01:00
Joakim Kronqvist 08df7abf27 Use osml10n functions for transportation name tags 2018-11-07 11:08:06 +01:00
jirik dba6e7025f Improve doc, update diagrams 2018-04-27 13:41:32 +02:00
jirik 63f6915fab Add missing transportation_name features
Fix #372
2017-11-25 11:10:01 +01:00
jirik e95f2d476b Add layer, level, and indoor tags for footways and steps 2017-11-09 10:13:53 +01:00
jirik 0b94704436 Add subclass of paths in transportation_name 2017-11-09 10:13:53 +01:00
jirik 14f6729f5c Update diagrams of transportation_name 2017-11-09 10:13:53 +01:00
jirik 1cdf726384 Add platforms to transportation as paths 2017-11-09 08:51:14 +01:00
jirik 893918761c Fix SQL update logic (patch from 3.6.2) 2017-08-01 09:12:15 +02:00
Jiri Kozel 51bc8fad35 Multilinguality (#279)
Improve multilinguality: names in 57 languages, name:latin, name:nonlatin, name_int. Fixes #211 #252 #80.

See #279 for more info.
2017-06-12 17:53:47 +02:00
jirik f829f6cd19 Update diagrams of transportation and transportation_name 2017-03-31 13:48:57 +02:00
jirik c6eed77e42 Remove memeber_osm_ids attribute from transportation and transportation_name
Too big DB during import-sql step
2017-03-31 13:48:57 +02:00
MartinMikita 13e8625862 Added partial index to speed up creating materialized views in transportation_name merge_highways SQL. 2017-03-31 13:48:57 +02:00
jirik 038d4d5224 Add name_de to documentation 2017-03-17 13:15:40 +01:00
jirik 4c6d30066d Add German names (name_de), unify English names (name_en) 2017-03-17 12:56:54 +01:00
jirik fad3cab2cd Adjust zoom levels of transportation_name, update diagrams 2017-03-15 13:53:09 +01:00
jirik c026da1324 Change default value of transportation_name's network attribute 2017-03-15 11:10:06 +01:00
jirik 6b523a5e0a Adjust zoom levels of transportation_name layer 2017-03-15 11:08:26 +01:00
jirik 4dcbb40ef1 Add gb-motorway and gb-trunk network types 2017-03-14 13:43:14 +01:00
jirik 7459cbe9c3 Add ca-transcanada network type 2017-03-03 14:05:39 +01:00
jirik 3af0204564 Fix order of commands in network_type.sql in transportation_name 2017-03-03 09:15:58 +01:00
jirik 5568d3ba44 Add default value to network attribute of layer_transportation_name 2017-03-01 15:59:10 +01:00
jirik 5db1b0e80e Add network type to transportation_name layer, adjust 'ref' attribute 2017-03-01 14:55:02 +01:00
jirik 3fa68ebef1 Remove empty string from network_type 2017-03-01 13:08:24 +01:00
jirik fdfeb1aa24 Add network_type to osm_route_member 2017-03-01 10:50:07 +01:00
jirik 4fd4bfb2a0 Add attribute into osm_transportation_name_linestring 2017-02-28 16:25:19 +01:00
jirik fa34831a54 Add attribute into osm_transportation_name_linestring 2017-02-28 16:23:47 +01:00
Lukas Martinelli 0fb7981bb9 Ensure empty name is NULL in name_en 2017-01-18 16:26:11 +01:00
Lukas Martinelli ce66892808 Replace tabs with spaces for merge_highways 2017-01-18 16:20:57 +01:00
Lukas Martinelli a123c1fbd9 Add name_en to transportation_name UNION 2017-01-18 16:20:24 +01:00
Lukas Martinelli 25fea38fe2 Add name_en to transportation_name #88 2017-01-18 16:13:37 +01:00
stirringhalo 6f842a6859 Switch st_union to st_collect 2017-01-16 20:54:10 -05:00
Lukas Martinelli 2d586bb47a Merge pull request #131 from openmaptiles/trigger_tables_sql
Daily updates
2017-01-16 09:38:47 +01:00
stirringhalo 31e0466b67 Disable concurrent refresh as its problematic. 2017-01-11 16:31:47 -05:00
stirringhalo 4c1ea3e4b1 Refresh concurrently and create materialized views with data. 2017-01-07 22:26:09 -05:00
stirringhalo cda3af9215 Change SELECT to PERFORM in function and drop triggers first 2017-01-06 20:33:43 -05:00
stirringhalo 9437a1b8d6 Make the sql rerunnable without error 2017-01-05 12:47:10 -05:00
Lukas Martinelli f361d3d9fd Add better title to layer READMEs 2017-01-05 17:31:21 +01:00
Lukas Martinelli 8a9b1246d3 Link to openmaptiles.org for layer doc 2017-01-05 17:29:18 +01:00
stirringhalo c5d4c1ea80 Fix the name of triggers, cannot be schema-qualified 2017-01-04 17:56:51 -05:00
stirringhalo 2fd3be1403 Use schemas to update on commit, untested 2017-01-04 16:59:42 -05:00
stirringhalo 3c4205055b Refresh concurrently 2017-01-04 11:49:14 -05:00
stirringhalo 2ef6a19149 when create materialized do so without data, better logging 2017-01-04 01:03:00 -05:00
stirringhalo 0c1da27294 Fix pile of syntax issues 2017-01-03 23:35:39 -05:00
stirringhalo 53c29f65cd fix semicolon 2017-01-03 23:21:52 -05:00
stirringhalo c64170d9be Initial materialized views and triggers 2017-01-02 18:31:24 -05:00
stirringhalo 8b30e5ddc2 Add cascade to drops 2016-12-28 18:19:54 -05:00
stirringhalo f98ade427e Drop tables to force redo on update
Reorder
2016-12-28 18:17:18 -05:00
ImreSamu f5ac3def5e etldoc fixes 2016-12-04 02:52:52 +01:00
Lukas Martinelli 681b50ff1c Remove subclass from transportation_name 2016-12-02 12:39:10 +00:00
Lukas Martinelli f3a507473e Merge branch 'master' into feature/transportation
Conflicts:
	Makefile
	layers/transportation/README.md
	layers/transportation/mapping.png
	layers/transportation_name/README.md
2016-11-30 18:59:46 +00:00
Lukas Martinelli 0cbc3fa896 Add values to transportation layers 2016-11-30 12:57:33 +00:00
Lukas Martinelli 21b12facc6 Create transportation name out of highway linestring 2016-11-30 08:48:13 +00:00
Lukas Martinelli de2f538ef5 Use new classes in transport_name and add network 2016-11-28 11:09:57 +00:00
Lukas Martinelli e9f4c31e0a Return railways in transportation 2016-11-26 21:08:30 +00:00
Lukas Martinelli 35b6951c81 Move highway and railway into transportation 2016-11-26 20:22:18 +00:00