Skip to content
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

We need to improve this SQL #134

Open
dadiorchen opened this issue Dec 1, 2022 · 0 comments
Open

We need to improve this SQL #134

dadiorchen opened this issue Dec 1, 2022 · 0 comments
Labels
wontfix This will not be worked on

Comments

@dadiorchen
Copy link
Contributor

The dag: refresh_webmap_db_org_location_view is trying to update the view in db:

org_location_view, the SQL of creating this materialized view is shown below, the problem is that it is too slow, and the updating will block following request against this view, so it makes everything down and gives a cascaded bad impact.

So to solve this problem, two possible solution:

  1. Find a way to safely update the view without blocking following request.
  2. Improve the performance of this SQL ( now it takes hours)
 SELECT entity.id,
    country.id AS country_id,
    country.name AS country_name,
    continent.id AS continent_id,
    continent.name AS continent_name
   FROM entity
     JOIN trees ON trees.id = (( SELECT tr.id
           FROM trees tr
          WHERE (tr.planter_id IN ( SELECT planter.id
                   FROM planter
                  WHERE (planter.organization_id IN ( SELECT getentityrelationshipchildren.entity_id
                           FROM getentityrelationshipchildren(entity.id) getentityrelationshipchildren(entity_id, p
arent_id, depth, type, relationship_role)))))
         LIMIT 1))
     JOIN region country ON st_within(trees.estimated_geometric_location, country.geom) AND (country.type_id IN ( S
ELECT region_type.id
           FROM region_type
          WHERE region_type.type::text = 'country'::text))
     JOIN region continent ON st_within(trees.estimated_geometric_location, continent.geom) AND (continent.type_id
IN ( SELECT region_type.id
           FROM region_type
          WHERE region_type.type::text = 'continents'::text))
  WHERE entity.type::text = 'o'::text OR entity.type::text = 'O'::text;
@dadiorchen dadiorchen added wontfix This will not be worked on and removed high-priority labels Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant