sort by host id to test iops cheese to improve icon read performance
This commit is contained in:
parent
03f6406e18
commit
a30fe104a3
2 changed files with 17 additions and 16 deletions
|
|
@ -7,24 +7,25 @@ import (
|
|||
)
|
||||
|
||||
type HostRow struct {
|
||||
ID int64
|
||||
Hostname string
|
||||
Protocol string
|
||||
HtmlTitle string
|
||||
IframeAllowed bool
|
||||
ID int64
|
||||
Hostname string
|
||||
Protocol string
|
||||
HtmlTitle string
|
||||
IframeAllowed bool
|
||||
BestIconHash string
|
||||
RandomOrder float64
|
||||
}
|
||||
|
||||
// fetchHostsPage gets a page of hosts with titles, ordered by random_order for shuffled bundles.
|
||||
func fetchHostsPage(ctx context.Context, pool *pgxpool.Pool, lastRandom float64, limit int) ([]HostRow, error) {
|
||||
// fetchHostsPage gets a page of hosts with titles, ordered by id for disk locality.
|
||||
// Icons were downloaded roughly in host-ID order, so reading by ID approximates
|
||||
// the physical write order on disk — improves EBS readahead cache hits.
|
||||
func fetchHostsPage(ctx context.Context, pool *pgxpool.Pool, lastID int64, limit int) ([]HostRow, error) {
|
||||
rows, err := pool.Query(ctx, `
|
||||
SELECT id, hostname, protocol, html_title, COALESCE(iframe_allowed, true), COALESCE(best_icon_hash, ''), random_order
|
||||
SELECT id, hostname, protocol, html_title, COALESCE(iframe_allowed, true), COALESCE(best_icon_hash, '')
|
||||
FROM hosts
|
||||
WHERE html_title IS NOT NULL AND random_order > $1
|
||||
ORDER BY random_order
|
||||
WHERE html_title IS NOT NULL AND id > $1
|
||||
ORDER BY id
|
||||
LIMIT $2
|
||||
`, lastRandom, limit)
|
||||
`, lastID, limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -33,7 +34,7 @@ func fetchHostsPage(ctx context.Context, pool *pgxpool.Pool, lastRandom float64,
|
|||
var hosts []HostRow
|
||||
for rows.Next() {
|
||||
var h HostRow
|
||||
if err := rows.Scan(&h.ID, &h.Hostname, &h.Protocol, &h.HtmlTitle, &h.IframeAllowed, &h.BestIconHash, &h.RandomOrder); err != nil {
|
||||
if err := rows.Scan(&h.ID, &h.Hostname, &h.Protocol, &h.HtmlTitle, &h.IframeAllowed, &h.BestIconHash); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hosts = append(hosts, h)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue