Skip to content

Commit

Permalink
added some results obtained with the first approach
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmkano committed Feb 15, 2021
1 parent 7404d0a commit e9f1c25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@ Make sure to run the following commands in your local postgres server before run
first_name character varying(70) NOT NULL DEFAULT '',
last_name character varying(70) NOT NULL DEFAULT '',
email character varying(70) NOT NULL DEFAULT '');

### Results

We didn't perform a proper benchmark of our queries but we added an statement in there to get an idea of how long it was taking for the insert to finish.
Here are the results obtained for the different versions used.

|Approach| Records Submitted |Time (ms) |
|--------|-----------|-------|
| Single Multi-insert statement|100|4.98245ms|
| Single Multi-insert statement|10000|234.610741ms|
| Single Multi-insert statement|20000|491.543135ms|
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

var (
DB *sql.DB
recordsToInsert = int(10000)
recordsToInsert = int(20000)
)

func setupDB() error {
Expand All @@ -32,6 +32,9 @@ func setupDB() error {
return nil
}

// First approach - Inserting 100 took 4.98245ms
// First approach - Inserting 10000 took 234.610741ms
// First approach - fails > PostgreSQL only supports 65535 parameters
func main() {
if err := setupDB(); err != nil {
log.Fatal(err)
Expand All @@ -46,5 +49,5 @@ func main() {
log.Fatal(err)
}

fmt.Printf("Inserting %d took %s", recordsToInsert, time.Since(n))
fmt.Printf("Inserting %d took %s\n", recordsToInsert, time.Since(n))
}

0 comments on commit e9f1c25

Please sign in to comment.