Skip to content

Commit 1af5c69

Browse files
committed
Process in much smaller chunks 1000 -> 100
Vastly faster for SQL inserts.
1 parent a5cd5cd commit 1af5c69

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

load.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func loadCities(dataToLoad DataToLoad) {
6969

7070
cities = append(cities, IpCity{ record[0], record[1], record[2], record[3], record[4], record[5], record[6], lat, lon, record[9], dataToLoad.Version, version })
7171

72-
if len(cities) == 1000 {
72+
if len(cities) == 100 {
7373
count += len(cities);
7474
fmt.Print("\033[u\033[K") // Restore the cursor position and clear the line
7575
fmt.Printf("Saved: %d entries\n", count)
@@ -110,7 +110,7 @@ func loadASNs(dataToLoad DataToLoad) {
110110
asn, _ := strconv.Atoi(record[2])
111111
ASNs = append(ASNs, IpASN{ record[0], record[1], asn, record[3], dataToLoad.Version, version })
112112

113-
if len(ASNs) == 1000 {
113+
if len(ASNs) == 100 {
114114
count += len(ASNs);
115115
fmt.Print("\033[u\033[K") // Restore the cursor position and clear the line
116116
fmt.Printf("Saved: %d entries\n", count)
@@ -150,7 +150,7 @@ func loadCountries(dataToLoad DataToLoad) {
150150
}
151151
countries = append(countries, IpCountry{ record[0], record[1], record[2], dataToLoad.Version, version })
152152

153-
if len(countries) == 1000 {
153+
if len(countries) == 100 {
154154
count += len(countries);
155155
fmt.Print("\033[u\033[K") // Restore the cursor position and clear the line
156156
fmt.Printf("Saved: %d entries\n", count)

0 commit comments

Comments
 (0)