DataTables serverSide: true: when to move large tables to the server
Use DataTables server-side processing for large tables, then verify the AJAX contract in your browser's Network tab.
09 Sept 2026, 23:00 UTC

The problem: forty thousand rows in one page
Your DataTables initialization works in staging. The dataset has a few hundred rows, so DataTables downloads everything, builds the DOM, and lets the browser handle paging, sorting, and searching locally. In production, the same table returns forty thousand rows. The initial JSON payload is megabytes, the browser tab freezes while it parses and inserts rows, and the user waits before the first page is even visible.
The useful takeaway: move paging, sorting, and global search to the server with serverSide: true, but only when the dataset is large enough to justify the extra HTTP requests. The browser then holds only the current page of rows, and the server becomes responsible for the DataTables AJAX contract.
What serverSide: true actually changes
With client-side processing, the default, DataTables receives the full dataset once and performs all interactions in JavaScript. Enabling server-side processing shifts that work to your backend. On every page change, sort, or global search, DataTables sends an AJAX request containing parameters such as:
start— the index of the first row to displaylength— how many rows the client wants on this pagesearch[value]— the current global search stringorder[0][column]andorder[0][dir]— the sorted column and direction
The server must respond with JSON that includes:
draw— an integer the client echoes back to match requests to responsesrecordsTotal— the total number of records in the database, unfilteredrecordsFiltered— the total after applying the current search filterdata— an array containing only the rows for the current page
This behavior is supported in DataTables 1.10.x. If you are using DataTables 2.x, verify the option names and request format against that release, because defaults and behavior can differ.
Worked example: initialize and inspect the request
Here is a minimal initialization for a table backed by a JSON API endpoint:
$('#users-table').DataTable({
serverSide: true,
ajax: {
url: '/api/users',
type: 'POST'
},
columns: [
{ data: 'id' },
{ data: 'name' },
{ data: 'email' },
{ data: 'role' }
]
});
When the user clicks a column header or changes the page length, DataTables posts something like this to /api/users:
{
"draw": 3,
"columns": [...],
"order": [ { "column": 1, "dir": "asc" } ],
"start": 20,
"length": 10,
"search": { "value": "", "regex": false }
}
Your endpoint should answer with only the requested page. A valid response shape looks like this:
{
"draw": 3,
"recordsTotal": 40000,
"recordsFiltered": 40000,
"data": [
{ "id": 21, "name": "Ada Lovelace", "email": "[contact removed]", "role": "admin" },
{ "id": 22, "name": "Grace Hopper", "email": "[contact removed]", "role": "editor" }
]
}
You can probe the endpoint manually from a terminal. Run this where you have network access to the API, replacing the URL and payload as needed:
curl -X POST https://api.example.com/api/users \
-H "Content-Type: application/json" \
-d '{"draw":1,"start":0,"length":10,"search":{"value":""},"order":[{"column":0,"dir":"asc"}]}'
Required checks: the request returns HTTP 200, the body is valid JSON, draw matches the request, recordsTotal and recordsFiltered are integers, and the data array contains no more rows than length. Risk: do not run this against an endpoint that mutates data unless you intend to trigger those mutations.
Verify it in the browser
- Open your browser's Developer Tools and select the Network tab.
- Load the page and confirm the first DataTables AJAX request appears.
- Click a column header. Confirm the next request sends
orderparameters and the responsedataarray contains only the new page's rows. - Change the page length. Confirm
lengthchanges in the request and the response echoesdraw,recordsTotal, andrecordsFilteredas integers.
If the browser still downloads all rows on initial load, or if the response is missing recordsTotal, server-side processing is not active or the backend contract is incomplete.
Trade-offs and when to skip it
Server-side processing adds latency to every sort, page, and search because each action requires a round trip to the server. There is no official DataTables server SDK, so your backend team must implement the request/response contract by hand. For small tables that fit comfortably in memory, client-side processing is simpler and faster after the initial load.
Use this approach when your row count is in the tens of thousands or more, or when the database already supports efficient filtering and sorting. Skip it for a few hundred rows, or when you cannot afford the backend work to build and maintain the endpoint.
Closing checklist
- Measure your production row count and initial payload size.
- Enable
serverSide: trueonly if the client-side cost is measurable. - Implement the endpoint to return
draw,recordsTotal,recordsFiltered, anddata. - Verify each interaction in the Network tab before deploying.