-
Notifications
You must be signed in to change notification settings - Fork 19
[WIP] feat: market 2.0 #508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
pqBatchSize := 20000 | ||
|
||
for k, _ := range toDownload { | ||
pqBatch.Queue(`SELECT id FROM parked_pieces WHERE piece_cid = $1 AND piece_padded_size = $2`, k.PieceCID.String(), int64(k.Size)).QueryRow(func(row pgx.Row) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a hack to make this 1 query total (no loop) with half the params:
SELECT id FROM parked_pieces WHERE CONCAT(piece_cid, STRING(piece_padded_size)) = ANY($1)
} | ||
} | ||
|
||
func insertPiecesInTransaction(ctx context.Context, tx *harmonydb.Tx, deal *mk20.Deal) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider adding batch-with-flush behavior, maybe keyed on the length of args list staying low (10,000)
if data.SourceHTTP != nil { | ||
var pieceID int64 | ||
// Attempt to select the piece ID first | ||
err = tx.QueryRow(`SELECT id FROM parked_pieces WHERE piece_cid = $1 AND piece_padded_size = $2`, data.PieceCID.String(), data.Size).Scan(&pieceID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider an UPSERT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reviewing types for now, didn't look at much beyond that, but generally things make sense.
Write deal validation logic testsTests: