Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The calculation itself is likely to be insignificant (whether done on server or client). What tends to be much more significant is the physical data retrieval (query execution plan, caching, clustering, partitioning etc.) and the transfer of that data from server to client.</p> <p>In this particular case, you are using the same query in both cases, so I'd expect that doing the calculation client-side will simply add (very little) time to the time that was necessary for the query itself in any case.</p> <p>However, if you had...</p> <pre><code>Select ProductPrice, ProductQty From Stock </code></pre> <p>...versus...</p> <pre><code>Select ProductPrice * ProductQty As Total From Stock </code></pre> <p>...I'd expect the second to be slightly faster: transferring (from server to client) a bunch of larger 2-field tuples (for the first query) is likely to take more time than transferring the same number of smaller 1-field tuples (for the second query). In addition to that, it would eat-up more of the available network bandwidth, affecting other concurrent clients.</p> <p>And if you ever need to filter<sup>1</sup> the data in any way, using server-side <code>WHERE</code> is likely to be <em>much</em> faster than fetching all the rows to the client just to discard most of the rows there. If you are interested in the topic of database performance, I warmly recommend taking a look at: <a href="http://use-the-index-luke.com/">Use The Index, Luke!</a></p> <p>Recommendations:</p> <ul> <li>Your "default" position should be to do as much as practically possible on the server.</li> <li>If in doubt, don't guess, instead <strong>measure</strong> on representative amounts of data (50000 rows hardly qualifies as "big" in database terms).</li> </ul> <hr> <p><sup>1</sup> Or aggregate (<code>SUM</code>, <code>AVG</code>, <code>MAX</code>...) or <code>JOIN</code> etc...</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