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

Sensor reading performance improvement #4464

Merged
merged 1 commit into from
Jan 11, 2024

Conversation

axelstudios
Copy link
Member

What's this PR do?

Removes a long, unnecessary COUNT query, which cuts query time by 40%

How should this be manually tested?

Browse to the sensors page for an org with, ideally, millions of readings

What are the relevant tickets?

#3328

@axelstudios axelstudios added the Enhancement Add this label if functionality was generally improved but not a full feature or maintentance. label Jan 5, 2024
@@ -51,8 +51,7 @@ def _usages_by_exact_times(self, page, per_page):
if self.showOnlyOccupiedReadings:
sensor_readings = sensor_readings.filter(is_occupied=True)

# order by id **greatly** speeds this up (cause of indexing, I think
Copy link
Contributor

Choose a reason for hiding this comment

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

you had me make a commit just to add this comment, why are you removing it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because that change is gone now in favor of a better one - also, you merged your PR before it was reviewed/approved, so I couldn't make the change there.

Comment on lines -82 to -83
if self.showOnlyOccupiedReadings:
sensor_readings = sensor_readings.filter(is_occupied=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why isn't this needed anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's already handled at the top, no need to do it twice

@axelstudios axelstudios merged commit 036122d into develop Jan 11, 2024
8 checks passed
@axelstudios axelstudios deleted the task/3328-additional-optimization branch January 11, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Add this label if functionality was generally improved but not a full feature or maintentance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants