// UpsertByDwIndicatorID 创建或者更新,返回最新的数据
func UpsertByDwIndicatorID(d *model.BiIndicator) error {
var err error
if nil == d || 0 == d.DwIndicatorID {
return errors.New("UpsertByDwIndicatorID error: BiIndicator nil or DwIndicatorID value is empty")
}
if _, err := QueryOne([]basemodel.Pair{
{K: "dw_indicator_id", V: d.DwIndicatorID},
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
数据库相关查询优化 | |
1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。 | |
2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如: | |
select id from t where num is null | |
可以在num上设置默认值0,确保表中num列没有null值,然后这样查询: | |
select id from t where num=0 | |
3.应尽量避免在 where 子句中使用!=或<>操作符,否则将引擎放弃使用索引而进行全表扫描。 | |
4.应尽量避免在 where 子句中使用 or 来连接条件,否则将导致引擎放弃使用索引而进行全表扫描,如: | |
select id from t where num=10 or num=20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SendEmail 发送邮件 | |
func SendEmail(conf *EmailConfig) error { | |
m := gomail.NewMessage() | |
m.SetHeader("From", conf.From) | |
m.SetHeader("To", conf.To...) | |
m.SetHeader("Subject", conf.Subject) | |
if conf.ContentType == EmailTextType { | |
m.SetBody("text/plain", conf.ContentBuffer.String()) | |
} else if conf.ContentType == EmailHTMLType { | |
m.SetBody("text/html", conf.ContentBuffer.String()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func spectreCase() error { | |
host := os.Getenv("SPECTRE_HOST") | |
key := os.Getenv("SPECTRE_KEY") | |
secret := os.Getenv("SPECTRE_SECRET") | |
if host == "" || key == "" || secret == "" { | |
fmt.Println("Error 环境变量SPECTRE_HOST、SPECTRE_KEY、SPECTRE_SECRET均不能为空") | |
} | |
var bucketName = "venus-table-bucket-test" | |
//var bucketName = "venus-table-bucket" //online |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package goroutinetimeout | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"testing" | |
"time" | |
"proto/bi/service/olap/service" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
ch := make(chan int, 4) | |
go write(ch) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
var wg sync.WaitGroup |
OlderNewer