Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • What about index on peaks.elevation like CREATE INDEX ... ON peaks USING btree (elevation)? Commented Feb 29, 2024 at 20:20
  • I can try that. But won't that just make the final sort more efficient (which is already sub-second so little to gain). The issue as I see it is that instead of doing the sort first, then checking (starting at the highest) only until it finds the first peak within the contour, it is checking all 3000+ peaks AND THEN doing the sort. Commented Feb 29, 2024 at 21:33
  • 1
    Please post the output of EXPLAIN ANALYZE <your_query>; and add info about table sizes, contour complexity (vertex counts) and current indexation. Commented Mar 1, 2024 at 10:21
  • 1
    Table sizes and EXPLAIN added. EXPLAIN ANALYZE would be pretty meaningless at present due to other activity on the database. Will add when current data processing ends. Commented Mar 2, 2024 at 19:58
  • The primary question remains however: will my 'faster query' above always return the highest peak? i.e.: Can I rely on the outer query to test the points returned by the inner query in the order they are presented by the inner query? Commented Mar 2, 2024 at 20:04