Optimize Postgres dataWriter.go
by Implementing Batch Insert and Update Operations
#1252
Labels
area/database
Issues related with database configurations
💎 Bounty
feature request
New feature or request
iteration
Improvement on an existing feature
Milestone
Problem Description
Currently, in the
internal/storage/postgres/dataWriter.go
file, theINSERT
andUPDATE
operations are performed individually for each tuple in theRelationTuplesTable
. This method can be inefficient, particularly when dealing with large volumes of data, as it increases network latency and places a higher load on the database server due to multiple query executions.Proposed Solution
Implement batch processing for
INSERT
andUPDATE
operations usingpgx
batch capabilities. This will reduce the number of round-trips to the database and improve the overall performance of the data writing process.Implementation Details
Batch Inserts:
pgx.Batch
to queue multipleINSERT
statements and execute them in a single batch. This is particularly useful when inserting multiple tuples intoRelationTuplesTable
.Batch Updates:
UPDATE
conditions into a singlepgx.Batch
and execute them together to minimize database interactions.Benefits
Considerations
This change is expected to significantly enhance the efficiency of data handling in the system, particularly when processing large datasets or under high transaction scenarios.
The text was updated successfully, but these errors were encountered: