在sql包中,Query和QueryRow之间是否有显著的性能差异?

huangapple go评论120阅读模式
英文:

Is there any significant performance difference between Query and QueryRow in the sql package?

问题

"database/sql"包中,即使在查询的末尾加上LIMIT 1;func (db *DB) Queryfunc (db *DB) QueryRow之间是否有显著的性能差异?

英文:

Is there any significant performance difference between the

func (db *DB) Query(query string, args ...interface{}) (*Rows, error)

and the

func (db *DB) QueryRow(query string, args ...interface{}) *Row

in the "database/sql" package even if you have LIMIT 1; at the end of your query?

答案1

得分: 3

区别在于函数调用的开销(与向数据库发送查询相比几乎没有)。QueryRow调用Query,然后将结果封装在sql.Row中。

英文:

The difference is the overhead of a function call (i.e., almost nothing, compared to sending a query to your database). QueryRow calls Query, and then wraps the results in an sql.Row.

huangapple
  • 本文由 发表于 2015年9月8日 08:57:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/32447756.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定