Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Seeing that this is a popular question I've decided to explain what I did 3 years ago that sped up the ASP script. </p> <p>The original script made heavy use of resizable arrays in order to store key-values, so I modified that code to use Scriting.Dictionary. Example:</p> <pre><code>Dim myDictionary Set myDictionary = Createobject("Scripting.Dictionary") myDictionary.item("key") = "value" </code></pre> <p>That is a lot faster then resizable arrays.</p> <p>Another big change is the concatenation of strings. The original script was full of:</p> <pre><code>S = "" S = S &amp; "First line&lt;br /&gt;" S = S &amp; "Second line&lt;br /&gt;" S = S &amp; "Third line line&lt;br /&gt;" Response.Write(S) </code></pre> <p>I modified this to:</p> <pre><code>Response.Write("First line&lt;br /&gt;") Response.Write("Second line&lt;br /&gt;") Response.Write("Third line&lt;br /&gt;") </code></pre> <p>This made a huge difference. The concatenation of strings is a huge bottleneck because the string is thrown away and then reinitialized.</p> <p>Another option is:</p> <pre><code>S = "First line&lt;br /&gt;" &amp; _ "Second line&lt;br /&gt;" &amp; _ "Third line line&lt;br /&gt;" Response.Write(S) </code></pre> <p>This is also a good tip for ASP.NET: Use a StringBuilder instead of concatenating strings.</p> <p>Another important change is context switching. The original code was full of:</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;%= rs("Col1") %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= rs("Col2") %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= rs("Col2") %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>The 3 context switches take up a lot of time so I modified to this:</p> <pre><code>&lt;% Response.Write("&lt;table&gt;") Response.Write("&lt;tr&gt;") Response.Write("&lt;td&gt;") Response.Write(rs("Col1")) Response.Write("&lt;/td&gt;") Response.Write("&lt;/tr&gt;") Response.Write("&lt;tr&gt;") Response.Write("&lt;td&gt;") Response.Write(rs("Col2")) Response.Write("&lt;/td&gt;") Response.Write("&lt;/tr&gt;") Response.Write("&lt;tr&gt;") Response.Write("&lt;td&gt;") Response.Write(rs("Col3")) Response.Write("&lt;/td&gt;") Response.Write("&lt;/tr&gt;") Response.Write("&lt;/table&gt;") %&gt; </code></pre> <p>Yes the code is very redundant but it performs better.</p> <p>Another small modification (which is actually a dirty hack) is to use WITH (NOLOCK) in your SQL queries:</p> <pre><code>conn.Query("SELECT * FROM MyTable WITH (NOLOCK) LEFT JOIN AnotherTable WITH (NOLOCK) ON MyTable.Id = AnotherTable.Id") </code></pre> <p>It makes a difference.</p> <p>Finally, I don't know if that helps much, but there was a lot of copy-pasted code that I refactored into clean functions. </p> <p>I hope that people finding this thead will find these tips useful.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload