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

[Surrey] Exclude Open311-fetched reports from cut_off_date #5182

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

davea
Copy link
Member

@davea davea commented Sep 20, 2024

@davea davea requested a review from dracos September 20, 2024 07:12
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

Attention: Patch coverage is 61.53846% with 5 lines in your changes missing coverage. Please review.

Project coverage is 82.32%. Comparing base (0a17904) to head (46fe8fc).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
perllib/FixMyStreet/Cobrand/Surrey.pm 61.53% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5182      +/-   ##
==========================================
- Coverage   82.35%   82.32%   -0.03%     
==========================================
  Files         409      409              
  Lines       31861    31878      +17     
  Branches     5067     5070       +3     
==========================================
+ Hits        26238    26244       +6     
- Misses       4127     4136       +9     
- Partials     1496     1498       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@davea davea force-pushed the surrey-show-old-open311-reports branch 2 times, most recently from d69018d to 0d3899b Compare September 20, 2024 08:06
Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think query code can be simplified, same outcome, is all :)

perllib/FixMyStreet/Cobrand/Surrey.pm Outdated Show resolved Hide resolved
perllib/FixMyStreet/Cobrand/Surrey.pm Outdated Show resolved Hide resolved
@davea davea force-pushed the surrey-show-old-open311-reports branch from 0d3899b to 3fcb82d Compare October 7, 2024 20:06
@davea
Copy link
Member Author

davea commented Oct 7, 2024

Based on my understanding of EXPLAIN ANALYZE output I don't think this will undo the improvements that came from adding the index on created, but would appreciate your opinion!

@davea davea requested a review from dracos October 7, 2024 20:24
Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the analyze when it's only created, you can see a 'nearby' query boils down to:

  1. Get the nearby problems using bitmap heap/index scan on problem_radians_latitude_longitude_idx
  2. Do a bitmap heap scan using bitmap index scans on both problem_bodies_str_array_idx and problem_created_idx, filtering out state/timestamp based (179 rows)
  3. hash together steps 1 and 2, filtering out shown reports
  4. sort/limit

With it also checking service, this becomes:

  1. Same - nearby problems using bitmap heap/index scan
  2. Can only use problem_bodies_str_array_idx now, so bitmap heap scan with that, filter out ones that don't match created/service/state/timestamp (46,317 rows)
  3. Same
  4. Same

Which is equivalent to what it does when there isn't a cut off date at all; still using a bitmap heap scan, so much better than when it was going wrong. Its runtime is comparable, but it is having to do quite a bit more 'work' (looking at the calculated cost, not the actual time). So yes, think it's fine, we might want to have a think of is there's something we can do to improve the general 'no cut off date' (or here) query, could another index on state, or perhaps a combined (state,created) or (created,state) index, or some other index for this common query help, for example?

@davea davea force-pushed the surrey-show-old-open311-reports branch from 96122e7 to 46fe8fc Compare October 9, 2024 09:21
@davea davea merged commit 46fe8fc into master Oct 9, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants