satellite/metainfo/metabase: improve subquery comparision performance
Comparing the result from a subquery with the "IN" operator instead of "=" makes a huge difference in the execution time of the SQL query on CockroachDB. Change-Id: I76e8f75a7bc95951667345d1ed9bd60f9aef3edb
This commit is contained in:
parent
da68f0cda7
commit
0f1961b7d1
@ -262,7 +262,7 @@ func (db *DB) DeleteObjectLatestVersion(ctx context.Context, opts DeleteObjectLa
|
||||
project_id = $1 AND
|
||||
bucket_name = $2 AND
|
||||
object_key = $3 AND
|
||||
version = (SELECT version FROM objects WHERE
|
||||
version IN (SELECT version FROM objects WHERE
|
||||
project_id = $1 AND
|
||||
bucket_name = $2 AND
|
||||
object_key = $3 AND
|
||||
|
@ -229,7 +229,7 @@ func (db *DB) GetLatestObjectLastSegment(ctx context.Context, opts GetLatestObje
|
||||
inline_data, remote_pieces
|
||||
FROM segments
|
||||
WHERE
|
||||
stream_id = (SELECT stream_id FROM objects WHERE
|
||||
stream_id IN (SELECT stream_id FROM objects WHERE
|
||||
project_id = $1 AND
|
||||
bucket_name = $2 AND
|
||||
object_key = $3 AND
|
||||
@ -284,7 +284,7 @@ func (db *DB) GetSegmentByOffset(ctx context.Context, opts GetSegmentByOffset) (
|
||||
inline_data, remote_pieces
|
||||
FROM segments
|
||||
WHERE
|
||||
stream_id = (SELECT stream_id FROM objects WHERE
|
||||
stream_id IN (SELECT stream_id FROM objects WHERE
|
||||
project_id = $1 AND
|
||||
bucket_name = $2 AND
|
||||
object_key = $3 AND
|
||||
|
Loading…
Reference in New Issue
Block a user