Skip to content

Commit

Permalink
chore: postgres index on union users table (#4879)
Browse files Browse the repository at this point in the history
  • Loading branch information
achettyiitr authored Jul 9, 2024
1 parent 98bf69a commit ec23141
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions warehouse/integrations/postgres/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,26 @@ func (pg *Postgres) loadUsersTable(
}
}

query = fmt.Sprintf(`
CREATE INDEX users_identifies_union_id_idx ON %[1]s (id);`,
unionStagingTableName,
)
pg.logger.Debugw("creating index on union staging users table",
logfield.SourceID, pg.Warehouse.Source.ID,
logfield.SourceType, pg.Warehouse.Source.SourceDefinition.Name,
logfield.DestinationID, pg.Warehouse.Destination.ID,
logfield.DestinationType, pg.Warehouse.Destination.DestinationDefinition.Name,
logfield.WorkspaceID, pg.Warehouse.WorkspaceID,
logfield.TableName, warehouseutils.UsersTable,
logfield.StagingTableName, usersStagingTableName,
logfield.Query, query,
)
if _, err = tx.ExecContext(ctx, query); err != nil {
return loadUsersTableResponse{
usersError: fmt.Errorf("creating index on union staging users table: %w", err),
}
}

query = fmt.Sprintf(`
CREATE TEMPORARY TABLE %[1]s AS (
SELECT
Expand Down

0 comments on commit ec23141

Please sign in to comment.