I'd attorney at law having a friend at the office, it had been about SQL queries and sorting. He's the opinion that you ought to allow the server inflict sorting before coming back the rows towards the client. I however thinks the server is most likely busy enough because it is, and it should be better for performance to allow the customer handle the sorting after it's fetched the rows.

Anybody which strategy is the best for the general performance of the multi-user system?

Generally, you need to allow the database perform the sorting, whether it does not possess the assets additional effectively you will want to change your database server.

To begin with, the database may curently have indexes around the fields you would like therefore it might be trivial for this to retrieve data in sorted order. Next, the customer can't sort the outcomes until it's these, when the server sorts the outcomes you will get process them one row at any given time, already sorted. Lastly, the database is most likely more effective compared to client machine and may most likely perform sorting more effectively.

I'm in support of Roberts answer, however i added a little into it.

I additionally favor the sorting of information in SQL Server, I've done many systems which have attempted to get it done around the client side as well as in nearly every situation we now have needed to re-write the procedure to be done inside SQL Server. Why you may request? We have two primary reasons.

  1. The quantity of data being sorted
  2. The necessity to implement proper paging because of #1

We cope with connects that demonstrate customers large teams of data, and using the energy of SQL Server to deal with sorting and paging is undoubtedly better carrying out than doing the work client side.

To place some amounts for this, a SQL Server Side sort to some client side sort within our atmosphere, no paging for either. Client side 28 seconds using XML for sorting, and Server side sort total load time 3 seconds.

It is dependent... Can there be paging involved? What is the max size the information set? May be the entire dataset have to be sorted exactly the same one of the ways constantly? or accordincg to user selection? Or, (if paging is involved), could it be just the records within the single page on client screen have to be sorted? (not normally acceptable) or does the whole dataset have to be sorted and page among the recently sorted set redisplayed?

What is the distribution of client hardware in comparison towards the processing needs of the sort operation?

final point here is It is the overall consumer experience (measured against price of course), which should take control of your decision... Generally client machines are reduced than servers, and maycause additional latency. ... ... But Exactly How frequently will clients request additional custom sort procedures after initial page load? (Client kind of data already on client is much faster than round trip...) But sorting on client always mandates that entire dataset be delivered to client on initial load... That delays initials page display.. which might require lazy loading, or AJAX, or any other technical difficulties to mitigate...

Sorting on server otoh, introduces additional scalability issues and could require that you simply increase the boxes towards the server farm to cope with additional load... if you are doing sorting in DB, and achieve that threshold, that may get complicated. (To scale on DB, you need to implement some readonly replication plan, as well as other solution that enables multiple servers (each doing processing) to talk about read only data)..

Generally To be sure using the sights expressed above that server-side sorting is generally what you want. However, you will find sometimes good reasons to do client-side sorting:

  • The type criteria are user-selectable or numerous. Within this situation, it might not be smart to go adding a shedload of indices towards the table - particularly if place performance is an issue. If some kind criteria are hardly ever used, a catalog is not always worthwhile since card inserts will outnumber chooses.
  • The type criteria can not be expressed in pure SQL [uncommon], or can not be indexed. It isn't always any faster client-side, however it takes load from the server.

The key factor to consider is the fact that while balancing the burden between effective clients and also the server might be advisable theoretically, just the server can maintain a catalog that is up-to-date on every place. Regardless of the client does, it's beginning having a non-indexed unsorted group of data.