Skip to content

Commit

Permalink
add index for key
Browse files Browse the repository at this point in the history
  • Loading branch information
spikelu2016 committed Jul 30, 2024
1 parent 4db5063 commit 9b1fcae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/bricksllm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ func main() {
log.Sugar().Fatalf("error create create at index for keys: %v", err)
}

err = store.CreateKeyIndexForKeys()
if err != nil {
log.Sugar().Fatalf("error create create at index for keys: %v", err)
}

err = store.CreateEventsTable()
if err != nil {
log.Sugar().Fatalf("error creating events table: %v", err)
Expand Down
15 changes: 15 additions & 0 deletions internal/storage/postgresql/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ func (s *Store) CreateCreateAtIndexForKeys() error {
return nil
}

func (s *Store) CreateKeyIndexForKeys() error {
createIndexQuery := `
CREATE INDEX IF NOT EXISTS key_idx ON keys(key);
`

ctxTimeout, cancel := context.WithTimeout(context.Background(), s.wt)
defer cancel()
_, err := s.db.ExecContext(ctxTimeout, createIndexQuery)
if err != nil {
return err
}

return nil
}

func (s *Store) GetKeys(tags, keyIds []string, provider string) ([]*key.ResponseKey, error) {
ctxTimeout, cancel := context.WithTimeout(context.Background(), s.rt)
defer cancel()
Expand Down

0 comments on commit 9b1fcae

Please sign in to comment.