Skip to content

Commit

Permalink
change to single column index
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed Mar 9, 2024
1 parent 374f0e4 commit a6ab95f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
from superset.migrations.shared.utils import table_has_index

table = "query"
index = "ix_query_user_id_sql_editor_id"
index = "ix_sql_editor_id"


def upgrade():
if not table_has_index(table, index):
op.create_index(
op.f(index),
table,
["user_id", "sql_editor_id"],
["sql_editor_id"],
unique=False,
)

Expand Down
7 changes: 2 additions & 5 deletions superset/models/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Query(
user_id = Column(Integer, ForeignKey("ab_user.id"), nullable=True)
status = Column(String(16), default=QueryStatus.PENDING)
tab_name = Column(String(256))
sql_editor_id = Column(String(256))
sql_editor_id = Column(String(256), index=True)
schema = Column(String(256))
sql = Column(MediumText())
# Query to retrieve the results,
Expand Down Expand Up @@ -128,10 +128,7 @@ class Query(
)
user = relationship(security_manager.user_model, foreign_keys=[user_id])

__table_args__ = (
sqla.Index("ti_user_id_changed_on", user_id, changed_on),
sqla.Index("ix_query_user_id_sql_editor_id", user_id, sql_editor_id),
)
__table_args__ = (sqla.Index("ti_user_id_changed_on", user_id, changed_on),)

def get_template_processor(self, **kwargs: Any) -> BaseTemplateProcessor:
return get_template_processor(query=self, database=self.database, **kwargs)
Expand Down

0 comments on commit a6ab95f

Please sign in to comment.