Commit 9fae5d6
committed
Add option to filter results by namespace
We now have at least two data-sets in the featureService: Who's on First
and Divipola. As such, we may want the ability to restrict results to
just features from one of the two data-sets (e.g. in a Fortis deployment
in Colombia we may want to only consider shapes from Divipola).
This change makes the assumption that we'll continue the current trend
of prefixing all ids with the data source from where they came, so if an
item has an id 1234 and came from the Who's on First dataset, we'll give
it an id like `wof-1234`. This is a reasonable pattern so it's fine to
make this assumption.
Adding a computed index on the id column lets us query the namespace with a
reasonable efficiency as the below query plan shows:
```
features=# explain analyze select id from features where lower(split_part(id,'-',1))='divipola';
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------
Bitmap Heap Scan on features (cost=47.06..8406.97 rows=2405 width=13) (actual time=0.977..7.781 rows=5879 loops=1)
Recheck Cond: (lower(split_part((id)::text, '-'::text, 1)) = 'divipola'::text)
Heap Blocks: exact=1236
-> Bitmap Index Scan on features_namespace_index (cost=0.00..46.46 rows=2405 width=0) (actual time=0.849..0.849 rows=5879 loops=1)
Index Cond: (lower(split_part((id)::text, '-'::text, 1)) = 'divipola'::text)
Planning time: 0.124 ms
Execution time: 8.653 ms
```1 parent 503d4b5 commit 9fae5d6
3 files changed
+9
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| 59 | + | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| |||
75 | 78 | | |
76 | 79 | | |
77 | 80 | | |
| 81 | + | |
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
134 | 138 | | |
135 | 139 | | |
136 | 140 | | |
| |||
0 commit comments