Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions datastore/postgres/distributionsbylayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ var (

func (s *IndexerStore) DistributionsByLayer(ctx context.Context, hash claircore.Digest, scnrs indexer.VersionedScanners) ([]*claircore.Distribution, error) {
const (
selectScanner = `
SELECT id
FROM scanner
WHERE name = $1
AND version = $2
AND kind = $3;
`
query = `
SELECT dist.id,
dist.name,
Expand All @@ -68,17 +61,9 @@ func (s *IndexerStore) DistributionsByLayer(ctx context.Context, hash claircore.
return []*claircore.Distribution{}, nil
}

// get scanner ids
scannerIDs := make([]int64, len(scnrs))
for i, scnr := range scnrs {
start := time.Now()
err := s.pool.QueryRow(ctx, selectScanner, scnr.Name(), scnr.Version(), scnr.Kind()).
Scan(&scannerIDs[i])
if err != nil {
return nil, fmt.Errorf("failed to retrieve distribution ids for scanner %q: %w", scnr, err)
}
distributionByLayerCounter.WithLabelValues("selectScanner").Add(1)
distributionByLayerDuration.WithLabelValues("selectScanner").Observe(time.Since(start).Seconds())
scannerIDs, err := s.selectScanners(scnrs)
if err != nil {
return nil, err
}

start := time.Now()
Expand Down
21 changes: 3 additions & 18 deletions datastore/postgres/filesbylayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ var (

func (s *IndexerStore) FilesByLayer(ctx context.Context, hash claircore.Digest, scnrs indexer.VersionedScanners) ([]claircore.File, error) {
const (
selectScanner = `
SELECT id
FROM scanner
WHERE name = $1
AND version = $2
AND kind = $3;
`
query = `
SELECT file.path, file.kind
FROM file_scanartifact
Expand All @@ -59,17 +52,9 @@ func (s *IndexerStore) FilesByLayer(ctx context.Context, hash claircore.Digest,
return []claircore.File{}, nil
}

// get scanner ids
scannerIDs := make([]int64, len(scnrs))
for i, scnr := range scnrs {
start := time.Now()
err := s.pool.QueryRow(ctx, selectScanner, scnr.Name(), scnr.Version(), scnr.Kind()).
Scan(&scannerIDs[i])
filesByLayerCounter.WithLabelValues("selectScanner").Add(1)
filesByLayerDuration.WithLabelValues("selectScanner").Observe(time.Since(start).Seconds())
if err != nil {
return nil, fmt.Errorf("failed to retrieve file ids for scanner %q: %w", scnr, err)
}
scannerIDs, err := s.selectScanners(scnrs)
if err != nil {
return nil, err
}

start := time.Now()
Expand Down
Loading
Loading