-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance issue #7
Comments
yes I see, the second query is much faster. Changing the query's needs to be done in the query builder (https://github.com/gost/server/blob/master/database/postgis/querybuilder.go), which can be a challenge regarding all functional requirements (from OGC test suite) and performance requirements for other queries. |
Another interesting optimisation example is requesting locations count from a thing that does not exist: Requesting an existing thingGost requestSELECT COUNT(DISTINCT A_location.location_id)
FROM (SELECT location.id AS location_id, location.name AS location_name,
location.description AS location_description,
location.encodingtype AS location_encodingtype,
location.geojson::text AS location_geojson
FROM v1.location
WHERE (SELECT thing.id AS thing_id
FROM v1.thing INNER JOIN v1.thing_to_location
ON thing.id = thing_to_location.thing_id
AND location.id = thing_to_location.location_id
WHERE thing.id = 1)
IS NOT NULL
ORDER BY location_id DESC)
AS A_location;
Optimised requestSELECT COUNT(DISTINCT location.id)
FROM v1.location, v1.thing_to_location
WHERE thing_to_location.thing_id = 1
AND location.id = thing_to_location.location_id;
Requesting a non-existing thingGost requestSELECT COUNT(DISTINCT A_location.location_id)
FROM (SELECT location.id AS location_id, location.name AS location_name,
location.description AS location_description,
location.encodingtype AS location_encodingtype,
location.geojson::text AS location_geojson
FROM v1.location
WHERE (SELECT thing.id AS thing_id
FROM v1.thing INNER JOIN v1.thing_to_location
ON thing.id = thing_to_location.thing_id
AND location.id = thing_to_location.location_id
WHERE thing.id = 4)
IS NOT NULL
ORDER BY location_id DESC)
AS A_location;
Optimised requestSELECT COUNT(DISTINCT location.id)
FROM v1.location, v1.thing_to_location
WHERE thing_to_location.thing_id = 4
AND location.id = thing_to_location.location_id;
It seems that using "simpler" requests enables the database engine to find earlier there's no entities to retrieve. |
nice work! Next step is to get these queries in the code in an optimized QueryBuilder without breaking things. However, as we are busy with other projects we can't work on this now. Let's see whats possible in between jobs. |
Hello again,
I think I managed to find a reproducible performance issue, using the same configuration as gost/server#171 with the GeoLife dataset (one thing, 2156994 locations).
Trying to get the locations count, hitting
v1.0/Things(1)/Locations?$count=true
executes this :The request leads the
postgres
to consume 100% of my i7-8650U CPU.Here is its plan:
Here is an refactored example of the request, which still consumes 100% of CPU, but resolves in around 3 seconds:
The text was updated successfully, but these errors were encountered: