Skip to content

Commit

Permalink
Fix generic query so limiting of data happens upfront and not at the …
Browse files Browse the repository at this point in the history
…end - performance improvement
  • Loading branch information
tconway committed Sep 5, 2016
1 parent 11e0eb2 commit ae53247
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions repository/models/queries/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,24 @@
SELECT ?{id_name} (MAX(?when) AS ?last_modified)
WHERE {{
?{id_name} a {class} .
OPTIONAL {{ ?{id_name} dcterm:modified ?when }}
{filter}
{{ SELECT ?{id_name} {{
?{id_name} a {class} .
OPTIONAL {{ ?{id_name} dcterm:modified ?when }}
{filter}
}} LIMIT {page_size}
OFFSET {offset}
}}
OPTIONAL {{ ?{id_name} dcterm:modified ?when }}
}}
GROUP BY ?{id_name}
}}
{extra_query}
}}
ORDER BY ?last_modified
LIMIT {page_size}
OFFSET {offset}
"""


INSERT_DATA = """
INSERT DATA {
%s
Expand Down

0 comments on commit ae53247

Please sign in to comment.