一個朋友的網站用php開發的,老是感受慢.php
我將其中的查詢sql server 代碼改爲go語言 (有7000多條記錄)java
都能感受到速度比之前快多了.git
努力繼續學go語言吧.github
php沒有使用任何框架.web
package main import ( _ "github.com/lunny/godbc" "github.com/go-xorm/xorm" "net/http" "fmt" ) func testweb(w http.ResponseWriter,r *http.Request) { const mssqlConnStr = "driver={SQL Server};Server=127.0.0.1,1592;Database=ddd; uid=; pwd=;" engine, err := xorm.NewEngine("odbc", mssqlConnStr) res, err := engine.Query("select top 10000 b_name,b_yz from book where b_sh=1 and b_id>10053") if err != nil { fmt.Println("",err) return } for i:=0;i<len(res);i++{ w.Write(res[i]["b_name"]) w.Write(res[i]["b_yz"]) } defer engine.Close() } func main() { http.HandleFunc("/",testweb) err:=http.ListenAndServe(":9999",nil) if err!=nil{ fmt.Println("listen and serve",err) } }