mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-06 10:00:24 +08:00
优化域名排行查询速度
This commit is contained in:
@@ -184,6 +184,7 @@ func (this *ServerDomainHourlyStatDAO) FindTopDomainStatsWithClusterId(tx *dbs.T
|
||||
Table(table).
|
||||
Attr("clusterId", clusterId).
|
||||
Between("hour", hourFrom, hourTo).
|
||||
UseIndex("hour").
|
||||
Result("domain, MIN(serverId) AS serverId, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||
Group("domain").
|
||||
Desc("countRequests").
|
||||
@@ -233,6 +234,7 @@ func (this *ServerDomainHourlyStatDAO) FindTopDomainStatsWithNodeId(tx *dbs.Tx,
|
||||
Table(table).
|
||||
Attr("nodeId", nodeId).
|
||||
Between("hour", hourFrom, hourTo).
|
||||
UseIndex("hour").
|
||||
Result("domain, MIN(serverId) AS serverId, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||
Group("domain").
|
||||
Desc("countRequests").
|
||||
@@ -282,6 +284,7 @@ func (this *ServerDomainHourlyStatDAO) FindTopDomainStatsWithServerId(tx *dbs.Tx
|
||||
Table(table).
|
||||
Attr("serverId", serverId).
|
||||
Between("hour", hourFrom, hourTo).
|
||||
UseIndex("hour").
|
||||
Result("domain, MIN(serverId) AS serverId, SUM(bytes) AS bytes, SUM(cachedBytes) AS cachedBytes, SUM(countRequests) AS countRequests, SUM(countCachedRequests) AS countCachedRequests, SUM(countAttackRequests) AS countAttackRequests, SUM(attackBytes) AS attackBytes").
|
||||
Group("domain").
|
||||
Desc("countRequests").
|
||||
|
||||
@@ -38,6 +38,9 @@ func TestServerDomainHourlyStatDAO_IncreaseHourlyStat(t *testing.T) {
|
||||
|
||||
for i := 0; i < 1_000_000; i++ {
|
||||
var f = string([]rune{int32(rands.Int('0', '9'))})
|
||||
if i % 30 > 0 {
|
||||
f = string([]rune{int32(rands.Int('a', 'z'))})
|
||||
}
|
||||
|
||||
err := NewServerDomainHourlyStatDAO().IncreaseHourlyStat(nil, 18, 48, 23, f+"rand"+types.String(i%500_000)+".com", timeutil.Format("Ymd")+fmt.Sprintf("%02d", rands.Int(0, 23)), 1, 1, 1, 1, 1, 1)
|
||||
if err != nil {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user