You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Select("collections.id as collection_id, collections.name as collection_name, collections.configuration_json_str, collections.dimension, collections.database_id AS database_id, collections.ts as collection_ts, collections.is_deleted, collections.created_at as collection_created_at, collections.updated_at as collection_updated_at, collections.log_position, collections.version, collections.version_file_name, collections.root_collection_id, NULLIF(collections.lineage_file_name, '') AS lineage_file_name, collections.total_records_post_compaction, collections.size_bytes_post_compaction, collections.last_compaction_time_secs, databases.name as database_name, databases.tenant_id as db_tenant_id, collections.tenant as tenant").
183
-
Joins("INNER JOIN databases ON collections.database_id = databases.id").
collection_targets:="collections.id as collection_id, collections.name as collection_name, collections.configuration_json_str, collections.dimension, collections.database_id AS database_id, collections.ts as collection_ts, collections.is_deleted, collections.created_at as collection_created_at, collections.updated_at as collection_updated_at, collections.log_position, collections.version, collections.version_file_name, collections.root_collection_id, NULLIF(collections.lineage_file_name, '') AS lineage_file_name, collections.total_records_post_compaction, collections.size_bytes_post_compaction, collections.last_compaction_time_secs, "
183
+
db_targets:=" databases.name as database_name, databases.tenant_id as db_tenant_id, "
184
+
collection_tenant:="collections.tenant as tenant"
185
+
186
+
ifisQueryOptimized {
187
+
db_id_query:=s.db.Model(&dbmodel.Database{}).
188
+
Select("id").
189
+
Where("tenant_id = ?", tenantID).
190
+
Where("name = ?", databaseName).
191
+
Limit(1)
192
+
193
+
// We rewrite the query to get the one database_id with what is hopefully an initplan
194
+
// that first gets the database_id and then uses it to do an ordered scan over
195
+
// the matching collections.
196
+
query=query.Select(collection_targets+"? as database_name, ? as db_tenant_id, "+collection_tenant, databaseName, tenantID).
0 commit comments