order by downloaded time to improve ebs read performance
This commit is contained in:
parent
df2eaa251c
commit
a799c05f81
4 changed files with 28 additions and 19 deletions
|
|
@ -135,6 +135,7 @@ func main() {
|
|||
// Stage 1: DB fetcher — continuously fetches pages into hostCh
|
||||
go func() {
|
||||
defer close(hostCh)
|
||||
var lastDownloaded *time.Time
|
||||
var lastID int64
|
||||
pageSize := 50000
|
||||
fetched := 0
|
||||
|
|
@ -150,14 +151,16 @@ func main() {
|
|||
}
|
||||
}
|
||||
fetchStart := time.Now()
|
||||
hosts, err := fetchHostsPage(ctx, pool, lastID, limit)
|
||||
hosts, err := fetchHostsPage(ctx, pool, lastDownloaded, lastID, limit)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to fetch hosts: %v", err)
|
||||
}
|
||||
if len(hosts) == 0 {
|
||||
break
|
||||
}
|
||||
lastID = hosts[len(hosts)-1].ID
|
||||
last := hosts[len(hosts)-1]
|
||||
lastDownloaded = last.IconDownloadedAt
|
||||
lastID = last.ID
|
||||
fmt.Printf("[fetcher] %d hosts in %dms (hostCh: %d/%d)\n",
|
||||
len(hosts), time.Since(fetchStart).Milliseconds(), len(hostCh), cap(hostCh))
|
||||
for _, h := range hosts {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue