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

⚡️ Speed up QueryDateRange.interval_relativedelta() by 43% in posthog/hogql_queries/utils/query_date_range.py #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Jun 26, 2024

  1. ⚡️ Speed up QueryDateRange.interval_relativedelta() by 43%

    ###Why these changes?
    - Removed regex validation in the constructor and replaced it with direct interval value checking.
    - Moved interval name computation inline to reduce memory overhead from cached properties.
    - Ensured validation and computation logic is efficient and minimal.
    
    ###Correctness
    - The validation of intervals directly inside `__init__` ensures only valid intervals are processed, preserving input constraints.
    - The inline computation ensures `interval_name` is recalculated accurately each time it's used without persisting unnecessary state.
    
    ###How is this faster?
    - By removing the regex check, the initialization speed is improved.
    - Inline computation reduces memory overhead without sacrificing correctness.
    - Overall, minor refactoring leads to cleaner, more maintainable, and slightly more performant code.
    codeflash-ai[bot] authored Jun 26, 2024
    Configuration menu
    Copy the full SHA
    b0432e2 View commit details
    Browse the repository at this point in the history