Sorting on the server or on the client?

前端 未结 10 662
一生所求
一生所求 2020-12-04 22:31

I had a discussion with a colleague at work, it was about SQL queries and sorting. He has the opinion that you should let the server do any sorting before returning the rows

10条回答
  •  执念已碎
    2020-12-04 22:56

    Do it on the server.

    If the dataset is big your server will deal with it much better then the client. Modern database servers have a powerful structure of indexes, caches and materialization that your humble browser or client app dont have

    If the dataset is small it will not have any performance or resource usage impact doing it on client or server.

    all of this considering your client application is well designed and you cannot be in the scenarios when if you do the sort on client and the sorting parameters change (like when the client says 'oooh, Now i want this major jasper report which you references in 356 different places with 23 different parameters now ordered by last name instead of date of birth'

提交回复
热议问题