Home > front end >  Questions about ASP query efficiency
Questions about ASP query efficiency

Time:10-23

A database, resource quantity 240000,

Basically, customer resource storage content in table 1: name, phone, add, add time
User information table 2 with 30 users information,

Do not regularly every day each user statistics, there are so many customers,
The current methods:
Strquery="select the name from o_user order by id asc"
Set the rs=conn. Execute (strquery)
If not rs. Bof then
Eof
the do while not rs.% & gt;
User: & lt; %=rs (" name ") % & gt; Customer number: & lt; Call the get %=rs (" name ") % & gt;


<%
Rs. Movenext
Loop
% & gt;

Customer number code is as follows: statistical user name because is 8 o 'clock to work every day, so is statistical data after 07:00:00, d is the date of the day, for example: 2020-10-11
<%
Sub getnum (user, d)
Dim objRSa
The Set objRSa=Conn. Execute (" SELECT COUNT (id) FROM o_connection WHERE addtime & gt; '" & amp; D&" 07:00:00 'and adduser=' "& amp; Trim (user) & amp;" '
")If Not objRSa. (bof) And Then Not objRSa. (eof)
CommNums=objRSa (0)
End the If
The Set objRSa=Nothing
Response. Write CommNums
End Sub
% & gt;

Above ways can run normally, can also be the accurate data, but the execution is slow, each time to refresh at least 30 to 40 seconds is as a result, the high efficient way please?

CodePudding user response:

The Set objRSa=Conn. Execute (" SELECT adduser, COUNT (id) FROM o_connection WHERE addtime & gt; '" & amp; D&" 07:00:00 'group by adduser ")
While Not objRSa. Eof
Response. Write "user:" & amp; ObjRSa (0) & amp;" Customer: "& amp; ObjRSa (1) & amp;"
"
ObjRSa. MoveNext
Wend

CodePudding user response:

refer to the second floor qq_63572063 response:
Set objRSa=Conn. Execute (" SELECT adduser, COUNT (id) FROM o_connection WHERE addtime & gt; '" & amp; D&" 07:00:00 'group by adduser ")
While Not objRSa. Eof
Response. Write "user:" & amp; ObjRSa (0) & amp;" Customer: "& amp; ObjRSa (1) & amp;"
"
ObjRSa. MoveNext
Wend


Just tested, you this method is of high efficiency, fast, but with a problem, if you have the user customer number is 0, is not to come out,

CodePudding user response:

The Set Dic=Server. CreateObject (" Scripting. The Dictionary ")
The Set objRSa=Conn. Execute (" SELECT adduser, COUNT (id) FROM o_connection WHERE addtime & gt; '" & amp; D&" 07:00:00 'group by adduser ")
While Not objRSa. Eof
Dic. Add objRSa (0), 1
Response. Write "user:" & amp; ObjRSa (0) & amp;" Customer: "& amp; ObjRSa (1) & amp;"
"
ObjRSa. MoveNext
Wend
Strquery="select the name from o_user order by id asc"
Set the rs=conn. Execute (strquery)
If not rs. Bof then
While Not Rs. Eof
If not Dic. The exists (rs (" name ")) then
Response. Write "user:" & amp; Rs (" name ") & amp;" Customer number: 0 & lt; Br>"
End the if
Rs. MoveNext
Wend
end if

CodePudding user response:

Thank you very much, I add a little further on this issue:
Customers also are classified. Such as are interested customers, potential customers, play of soy sauce, etc. Customer category (typed) respectively, with a, b, c, d

If the list? Display:
User: the total number of customers: intention client: potential customers:


Thank you very much!
  •  Tags:  
  • ASP
  • Related