Hur ska jag skriva om denna kod så att den kan bli snabbare? Du kan ju testa med detsnabbare lösning till forum
<code>
Antalinlagg = 50 '30, 50, 60, 90, 120, 150
Set RecSet = Server.CreateObject("ADODB.Recordset")
Addera = "SELECT *, convert(nvarchar(16), [datum], 20) AS Datum FROM NoNHQForum where ReadID = 0 ORDER BY Senastesvar DESC"
RecSet.Open Addera, Connect, adOpenStatic, adLockOptimistic
If Request.QueryString("next") = "" or Request.QueryString("next") = "0" Then
Nasta = 1
ElseIf Request.QueryString("next") > 0 Then
Nasta = Request.QueryString("next")
Nasta = Request.QueryString("next") -- 1
Steg = Request.QueryString("next") * Antalinlagg
RecSet.Move Steg
End If
For i = 1 to Antalinlagg
If RecSet.EOF Then
Exit for
End If
Set RecSetAntla = Server.CreateObject("ADODB.Recordset")
Addera = "SELECT Count(*) AS ItemCount FROM NoNHQForum where ReadID = " & RecSet("ID") & ""
RecSetAntla.Open Addera, Connect, adOpenStatic, adLockOptimistic
Response.Write RecSet("Rubrik") & " " & RecSetAntla("ItemCount") & " " & RecSet("Datum")
RecSetAntla.Close
Set RecSetAntla = Nothing
Next
RecSet.Close
Set RecSet= Nothing
</code>
Tack på förhand!Sv: snabbare lösning till forum
<code>
Antalinlagg = 50 '30, 50, 60, 90, 120, 150
Set RecSet = Server.CreateObject("ADODB.Recordset")
Addera = "SELECT Main.*, convert(nvarchar(16), Main.[datum], 20) AS Datum, (SELECT Count(*) FROM NoNHQForum Sub WHERE Sub.ReadID = Main.ID) AS ItemCount" & vbCrLf & _
"FROM NoNHQForum Main" & vbCrLf & _
"WHERE Main.ReadID = 0" & vbCrLf & _
"ORDER BY Main.Senastesvar DESC"
RecSet.Open Addera, Connect
If Request.QueryString("next") = "" or Request.QueryString("next") = "0" Then
Nasta = 1
ElseIf Request.QueryString("next") > 0 Then
Nasta = CLng(st.QueryString("next")) - 1
Steg = Request.QueryString("next") * Antalinlagg
RecSet.Move Steg
End If
For i = 1 to Antalinlagg
If RecSet.EOF Then Exit for
Response.Write RecSet("Rubrik") & " " & RecSet("ItemCount") & " " & RecSet("Datum")
Next
RecSet.Close
Set RecSet= Nothing
</code>