Skip to content

Commit 3cb13a8

Browse files
authored
Remove use of temp tables / cursor in search (#175)
* remove use of temp tables / cursor in search * update changelog
1 parent 58a5743 commit 3cb13a8

18 files changed

+5238
-293
lines changed

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [v0.7.4]
8+
9+
### Added
10+
- Add --v and --vv options to scripts/test to change logging to notice / log when running tests.
11+
- Add framework for option to cache expensive item formatting/hydrating calls. Note: this only provides functionality to add and read from the cached calls, but does not have any wiring to remove any entries from the cache.
12+
- Update the costs for json formatting functions to 5000 to help the query planner choose to prefer using indexes on json fields.
13+
14+
### Fixed
15+
- Fix bug in foreign key and unique collection detection in queryables trigger function, update tests to catch.
16+
- Add collection id to tokens to ensure uniqueness and improve speed when looking up token values. Update tests to use the new keys. Old item id only tokens are still valid, but new results will all contain the new keys.
17+
- Improve performance when looking for whether next/prev links should be added.
18+
- Update Search function to remove the use of cursors and temp tables.
19+
- Update get_token_filter to remove the use of temp tables.
20+
21+
722
## [v0.7.3]
823

924
### Fixed

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ RUN set -ex \
1616
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
1717
postgresql-$PG_MAJOR-pgtap \
1818
postgresql-$PG_MAJOR-partman \
19+
postgresql-$PG_MAJOR-plpgsql-check \
1920
&& apt-get remove -y apt-transport-https \
2021
&& apt-get clean && apt-get -y autoremove \
2122
&& rm -rf /var/lib/apt/lists/* \

scripts/bin/test

+34-13
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ cd /opt/src/pgstac
4747
TEMPLATEDB=${1:-pgstac_test_db_template}
4848
psql -X -q -v ON_ERROR_STOP=1 <<EOSQL
4949
CREATE DATABASE pgstac_test_pgtap TEMPLATE $TEMPLATEDB;
50+
ALTER DATABASE pgstac_test_pgtap SET client_min_messages to $CLIENTMESSAGES;
5051
EOSQL
5152
TESTOUTPUT=$(psql -X -q -v ON_ERROR_STOP=1 -f /opt/src/pgstac/tests/pgtap.sql pgstac_test_pgtap)
5253
psql -X -q -v ON_ERROR_STOP=1 <<EOSQL
@@ -67,7 +68,8 @@ TEMPLATEDB=${1:-pgstac_test_db_template}
6768
cd /opt/src/pgstac
6869
psql -X -q -v ON_ERROR_STOP=1 <<EOSQL
6970
CREATE DATABASE pgstac_test_basicsql TEMPLATE $TEMPLATEDB;
70-
ALTER DATABASE pgstac_test_basicsql SET search_path to pgstac, public;ALTER DATABASE pgstac_test_basicsql SET client_min_messages to warning;
71+
ALTER DATABASE pgstac_test_basicsql SET search_path to pgstac, public;
72+
ALTER DATABASE pgstac_test_basicsql SET client_min_messages to $CLIENTMESSAGES;
7173
ALTER DATABASE pgstac_test_basicsql SET pgstac.context to 'on';
7274
ALTER DATABASE pgstac_test_basicsql SET pgstac."default_filter_lang" TO 'cql-json';
7375
\connect pgstac_test_basicsql
@@ -100,6 +102,7 @@ TEMPLATEDB=${1:-pgstac_test_db_template}
100102
cd /opt/src/pypgstac
101103
psql -X -q -v ON_ERROR_STOP=1 <<EOSQL
102104
CREATE DATABASE pgstac_test_pypgstac TEMPLATE $TEMPLATEDB;
105+
ALTER DATABASE pgstac_test_pypgstac SET client_min_messages to $CLIENTMESSAGES;
103106
EOSQL
104107
pytest tests -o cache_dir=/tmp/.pytest_cache
105108
psql -X -q -c "DROP DATABASE pgstac_test_pypgstac WITH (force)";
@@ -108,7 +111,8 @@ EOSQL
108111
function test_migrations(){
109112
psql -X -q -v ON_ERROR_STOP=1 <<EOSQL
110113
CREATE DATABASE pgstac_test_migration;
111-
ALTER DATABASE pgstac_test_migration SET search_path to pgstac, public;ALTER DATABASE pgstac_test_migration SET client_min_messages to warning;
114+
ALTER DATABASE pgstac_test_migration SET search_path to pgstac, public;
115+
ALTER DATABASE pgstac_test_migration SET client_min_messages to $CLIENTMESSAGES;
112116
EOSQL
113117
export PGDATABASE=pgstac_test_migration
114118
echo "Migrating from version 0.1.9"
@@ -131,17 +135,10 @@ PGTAP=0
131135
BASICSQL=0
132136
PYPGSTAC=0
133137
MIGRATIONS=0
138+
MESSAGENOTICE=0
139+
MESSAGELOG=0
134140

135-
if [ $# -eq 0 ]
136-
then
137-
FORMATTING=1
138-
SETUPDB=1
139-
PGTAP=1
140-
BASICSQL=1
141-
PYPGSTAC=1
142-
MIGRATIONS=1
143-
else
144-
while [[ $# -gt 0 ]]
141+
while [[ $# -gt 0 ]]
145142
do
146143
key="$1"
147144
case $key in
@@ -152,6 +149,16 @@ else
152149
shift
153150
;;
154151

152+
--v)
153+
MESSAGENOTICE=1
154+
shift
155+
;;
156+
157+
--vv)
158+
MESSAGELOG=1
159+
shift
160+
;;
161+
155162
--formatting)
156163
FORMATTING=1
157164
shift
@@ -186,7 +193,6 @@ else
186193
PGTAP=1
187194
BASICSQL=1
188195
PYPGSTAC=1
189-
190196
shift
191197
;;
192198

@@ -196,6 +202,21 @@ else
196202
;;
197203
esac
198204
done
205+
206+
207+
CLIENTMESSAGES='warning'
208+
[ $MESSAGENOTICE -eq 1 ] && CLIENTMESSAGES='notice'
209+
[ $MESSAGELOG -eq 1 ] && CLIENTMESSAGES='log'
210+
echo $CLIENTMESSAGES
211+
212+
if [[ ($FORMATTING -eq 0) && ($SETUPDB -eq 0) && ($PGTAP -eq 0) && ($BASICSQL -eq 0) && ($PYPGSTAC -eq 0) && ($MIGRATIONS -eq 0) ]]
213+
then
214+
FORMATTING=1
215+
SETUPDB=1
216+
PGTAP=1
217+
BASICSQL=1
218+
PYPGSTAC=1
219+
MIGRATIONS=1
199220
fi
200221

201222
[ $FORMATTING -eq 1 ] && test_formatting

0 commit comments

Comments
 (0)