Skip to content
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

libvuln SQL: POC to introduce bulk inserts #996

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vishnuchalla
Copy link

@vishnuchalla vishnuchalla commented Jul 5, 2023

Description

POC to demonstrate the usage and benefits of executing bulk queries on postgres.
Related JIRA: https://issues.redhat.com/browse/PROJQUAY-5680
Related GitHub Issue: #995

Previously we used to have 1000 separate INSERT statements for one of the insert option on vuln table as below

#### Query 1
INSERT INTO target_table (column1, column2, ...)
VALUES (value1_1, value2_1, ...)
ON CONFLICT DO NOTHING

#### Query 2
INSERT INTO target_table (column1, column2, ...)
VALUES (value1_1, value2_1, ...)
ON CONFLICT DO NOTHING

#### Query 1000
INSERT INTO target_table (column1, column2, ...)
VALUES (value1_1, value2_1, ...)
ON CONFLICT DO NOTHING

Now we have modified the same operation to occur in a single query to do same amount of inserts in bulk as below

INSERT INTO target_table (column1, column2, ...)
VALUES
  Row 1 - (value1_1, value2_1, ...),
  Row 2 - (value1_2, value2_2, ...),
  .
  .
  .
  Row 1000 - (value1_1000, value2_1000, ...)
  ...
ON CONFLICT DO NOTHING

Testing

Tested building a new clair image

POC to demonstrate the usage and benefits of executing bulk queries.

Signed-off-by: vishnuchalla <[email protected]>
@hdonnay
Copy link
Member

hdonnay commented Sep 15, 2023

Making a note so I don't forget and it doesn't look like this is totally languishing: I've got a local branch that incorporates these ideas (albeit in a less strcat-y fashion) into a re-org of the internals of the datastore/postgres package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants