Improve chunking when inserting derivation inputs
Chunk the values inserted in the query, rather than the derivations involved, as this is more consistent.
This commit is contained in:
parent
7050ea749f
commit
78a5abee21
1 changed files with 34 additions and 37 deletions
|
|
@ -1381,7 +1381,6 @@ WHERE derivation_source_files.store_path = $1"
|
||||||
#f)))
|
#f)))
|
||||||
|
|
||||||
(define (insert-derivation-inputs conn derivation-ids derivations)
|
(define (insert-derivation-inputs conn derivation-ids derivations)
|
||||||
(define (process-chunk derivation-ids derivations)
|
|
||||||
(let ((query-parts
|
(let ((query-parts
|
||||||
(append-map!
|
(append-map!
|
||||||
(lambda (derivation-id derivation)
|
(lambda (derivation-id derivation)
|
||||||
|
|
@ -1406,7 +1405,8 @@ WHERE derivation_source_files.store_path = $1"
|
||||||
derivation-ids
|
derivation-ids
|
||||||
derivations)))
|
derivations)))
|
||||||
|
|
||||||
(unless (null? query-parts)
|
(chunk-for-each!
|
||||||
|
(lambda (query-parts-chunk)
|
||||||
(exec-query
|
(exec-query
|
||||||
conn
|
conn
|
||||||
(string-append
|
(string-append
|
||||||
|
|
@ -1414,18 +1414,15 @@ WHERE derivation_source_files.store_path = $1"
|
||||||
INSERT INTO derivation_inputs (derivation_id, derivation_output_id)
|
INSERT INTO derivation_inputs (derivation_id, derivation_output_id)
|
||||||
SELECT vals.derivation_id, derivation_outputs.id
|
SELECT vals.derivation_id, derivation_outputs.id
|
||||||
FROM (VALUES "
|
FROM (VALUES "
|
||||||
(string-join query-parts ", ")
|
(string-join query-parts-chunk ", ")
|
||||||
") AS vals (derivation_id, file_name, output_name)
|
") AS vals (derivation_id, file_name, output_name)
|
||||||
INNER JOIN derivations
|
INNER JOIN derivations
|
||||||
ON derivations.file_name = vals.file_name
|
ON derivations.file_name = vals.file_name
|
||||||
INNER JOIN derivation_outputs
|
INNER JOIN derivation_outputs
|
||||||
ON derivation_outputs.derivation_id = derivations.id
|
ON derivation_outputs.derivation_id = derivations.id
|
||||||
AND vals.output_name = derivation_outputs.name")))))
|
AND vals.output_name = derivation_outputs.name")))
|
||||||
|
1000
|
||||||
(chunk-for-each! process-chunk
|
query-parts)))
|
||||||
200
|
|
||||||
(list-copy derivation-ids)
|
|
||||||
(list-copy derivations)))
|
|
||||||
|
|
||||||
(define (select-from-derivation-source-files store-paths)
|
(define (select-from-derivation-source-files store-paths)
|
||||||
(string-append
|
(string-append
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue