同样的事务,一个复杂的SQL完成的效率高于一堆简单SQL完成的效率。有多个查询时,要善于使用JOIN。 oRs=oConn.Execute("SELECT * FROM Books") while not oRs.Eof strSQL = "SELECT * FROM Authors WHERE AuthorID="&oRs("AuthorID") oRs2=oConn.Execute(strSQL) Response.write oRs("Title")&">>"&oRs2("Name")&" &q uot; oRs.MoveNext() wend 要比下面的代码慢: strSQL="SELECT Books.Title,Authors.Name FROM Books JOIN Authors ON Authors.AuthorID=Books.AuthorID" oRs=oConn.Execute(strSQL) while not oRs.Eof Response.write oRs("Title")&">>"&oRs("Name")&" &qu ot; oRs.MoveNext() wend
方法二、尽量避免使用可更新 Recordset
oRs=oConn.Execute("SELECT * FROM Authors WHERE AuthorID=17",3,3)
oRs("Name")="DarkMan"
oRs.Update()
要比下面的代码慢: strSQL = "UPDATE Authors SET Name='DarkMan' WHERE AuthorID=17" oConn.Execute strSQL