Skip to content

Commit 9688790

Browse files
EXPEbdodlaBhargav Dodla
and
Bhargav Dodla
authored
perf: Added indexes to sql tables to optimize query execution (feast-dev#4538)
minor: Added indexes to sql tables to optimize query execution Signed-off-by: Bhargav Dodla <bdodla@expediagroup.com> Co-authored-by: Bhargav Dodla <bdodla@expediagroup.com>
1 parent cecca83 commit 9688790

File tree

1 file changed

+24
-0
lines changed
  • sdk/python/feast/infra/registry

1 file changed

+24
-0
lines changed

sdk/python/feast/infra/registry/sql.py

+24
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from sqlalchemy import ( # type: ignore
1111
BigInteger,
1212
Column,
13+
Index,
1314
LargeBinary,
1415
MetaData,
1516
String,
@@ -82,6 +83,8 @@
8283
Column("project_proto", LargeBinary, nullable=False),
8384
)
8485

86+
Index("idx_projects_project_id", projects.c.project_id)
87+
8588
entities = Table(
8689
"entities",
8790
metadata,
@@ -91,6 +94,8 @@
9194
Column("entity_proto", LargeBinary, nullable=False),
9295
)
9396

97+
Index("idx_entities_project_id", entities.c.project_id)
98+
9499
data_sources = Table(
95100
"data_sources",
96101
metadata,
@@ -100,6 +105,8 @@
100105
Column("data_source_proto", LargeBinary, nullable=False),
101106
)
102107

108+
Index("idx_data_sources_project_id", data_sources.c.project_id)
109+
103110
feature_views = Table(
104111
"feature_views",
105112
metadata,
@@ -111,6 +118,8 @@
111118
Column("user_metadata", LargeBinary, nullable=True),
112119
)
113120

121+
Index("idx_feature_views_project_id", feature_views.c.project_id)
122+
114123
stream_feature_views = Table(
115124
"stream_feature_views",
116125
metadata,
@@ -121,6 +130,8 @@
121130
Column("user_metadata", LargeBinary, nullable=True),
122131
)
123132

133+
Index("idx_stream_feature_views_project_id", stream_feature_views.c.project_id)
134+
124135
on_demand_feature_views = Table(
125136
"on_demand_feature_views",
126137
metadata,
@@ -131,6 +142,8 @@
131142
Column("user_metadata", LargeBinary, nullable=True),
132143
)
133144

145+
Index("idx_on_demand_feature_views_project_id", on_demand_feature_views.c.project_id)
146+
134147
feature_services = Table(
135148
"feature_services",
136149
metadata,
@@ -140,6 +153,8 @@
140153
Column("feature_service_proto", LargeBinary, nullable=False),
141154
)
142155

156+
Index("idx_feature_services_project_id", feature_services.c.project_id)
157+
143158
saved_datasets = Table(
144159
"saved_datasets",
145160
metadata,
@@ -149,6 +164,8 @@
149164
Column("saved_dataset_proto", LargeBinary, nullable=False),
150165
)
151166

167+
Index("idx_saved_datasets_project_id", saved_datasets.c.project_id)
168+
152169
validation_references = Table(
153170
"validation_references",
154171
metadata,
@@ -157,6 +174,7 @@
157174
Column("last_updated_timestamp", BigInteger, nullable=False),
158175
Column("validation_reference_proto", LargeBinary, nullable=False),
159176
)
177+
Index("idx_validation_references_project_id", validation_references.c.project_id)
160178

161179
managed_infra = Table(
162180
"managed_infra",
@@ -167,6 +185,8 @@
167185
Column("infra_proto", LargeBinary, nullable=False),
168186
)
169187

188+
Index("idx_managed_infra_project_id", managed_infra.c.project_id)
189+
170190
permissions = Table(
171191
"permissions",
172192
metadata,
@@ -176,6 +196,8 @@
176196
Column("permission_proto", LargeBinary, nullable=False),
177197
)
178198

199+
Index("idx_permissions_project_id", permissions.c.project_id)
200+
179201

180202
class FeastMetadataKeys(Enum):
181203
LAST_UPDATED_TIMESTAMP = "last_updated_timestamp"
@@ -191,6 +213,8 @@ class FeastMetadataKeys(Enum):
191213
Column("last_updated_timestamp", BigInteger, nullable=False),
192214
)
193215

216+
Index("idx_feast_metadata_project_id", feast_metadata.c.project_id)
217+
194218
logger = logging.getLogger(__name__)
195219

196220

0 commit comments

Comments
 (0)