Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It shouldn't be slow. Optimize your query and database structure (at least indexes and statistcs if it's SQL Server). Maybe there is some other thing in your query other than <code>ORDER BY</code> which causes this slowness?</p> <pre><code>SELECT A.NAME, B.SYNTAX, B.DESCRIPTION, A.RATE1, A.RATE2, A.RATE3, A.STARTDATE, A.ENDDATE, A.HIDE, A.CATEGORYNAME FROM Table1 A JOIN Table2 B on A.Name = B.Name WHERE A.MODULENAME = @ModuleName AND A.PREVIOUS&lt;&gt;'N' OR A.PREVIOUS IS NULL ORDER BY A.NAME </code></pre> <h2>Option 1</h2> <p>If you're quering just a few simple columns (2-4), you can include them into the index as well. This way your query will be ran faster. Also make sure that sorting order on that index column matches sorting order in your query.</p> <pre><code>// if your query looks like this: SELECT [Name], [Title], [Count] ORDER BY [COUNT] // you can create an index on [Name], [Title], [Count] </code></pre> <h2>Option 3</h2> <p>Create a <code>view</code> and bind it to the <code>schema</code>. Then query data from that <code>view</code>.</p> <h2>Option 3</h2> <p>If you use <code>SQL Server 2005</code> and obove, you can also try to run you query in <strong>SQL Server Profiler</strong> and it will recommend to you the best index and statistics which you can apply to your table in order to optimize this particular query's performance.</p> <h2>Option 4</h2> <p>Try to rebuild your indexes and statistics.</p> <h2>Option 5</h2> <p>You can try putting you index/table into separate filegroup on different hard drive.</p>
 

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