Skip to content

Commit

Permalink
Revert "perf: Speed up create_hogql_database" (#27529)
Browse files Browse the repository at this point in the history
  • Loading branch information
timgl authored Jan 15, 2025
1 parent 97af0ac commit b174f22
Show file tree
Hide file tree
Showing 4 changed files with 2,507 additions and 2,508 deletions.
3 changes: 0 additions & 3 deletions posthog/hogql/database/schema/channel_type.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from dataclasses import dataclass
from typing import Optional, Union
from datetime import timedelta
from posthog.cache_utils import cache_for

from posthog.hogql import ast
from posthog.hogql.database.models import ExpressionField
Expand Down Expand Up @@ -62,7 +60,6 @@ def create_initial_domain_type(name: str):
)


@cache_for(timedelta(minutes=30))
def create_initial_channel_type(name: str, custom_rules: Optional[list[CustomChannelRule]] = None):
return ExpressionField(
name=name,
Expand Down
5 changes: 2 additions & 3 deletions posthog/hogql/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ def prepare_ast_for_printing(
stack: Optional[list[ast.SelectQuery]] = None,
settings: Optional[HogQLGlobalSettings] = None,
) -> _T_AST | None:
if context.database is None:
with context.timings.measure("create_hogql_database"):
context.database = create_hogql_database(context.team_id, context.modifiers, context.team)
with context.timings.measure("create_hogql_database"):
context.database = context.database or create_hogql_database(context.team_id, context.modifiers, context.team)

context.modifiers = set_default_in_cohort_via(context.modifiers)

Expand Down
3 changes: 0 additions & 3 deletions posthog/hogql/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from posthog.hogql.resolver_utils import extract_select_queries
from posthog.models.team import Team
from posthog.clickhouse.query_tagging import tag_queries
from posthog.hogql.database.database import create_hogql_database
from posthog.client import sync_execute
from posthog.schema import (
HogQLQueryResponse,
Expand Down Expand Up @@ -57,8 +56,6 @@ def execute_hogql_query(

if context is None:
context = HogQLContext(team_id=team.pk)
with context.timings.measure("create_hogql_database"):
context.database = create_hogql_database(team.pk, modifiers, team_arg=team)

query_modifiers = create_default_modifiers_for_team(team, modifiers)
debug = modifiers is not None and modifiers.debug
Expand Down
Loading

0 comments on commit b174f22

Please sign in to comment.