I am displaying a 20k row datatable through django. It is very slow to render. database is sql.
I am displaying a 20k row datatable through django. It is very slow to render. database is sql.
Nishtha
Posts: 6Questions: 2Answers: 0
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="call">
<div class="spacer"></div>
<table id="example" class="table table-bordered" style="width:100%">
<thead>
<tr>
<th> Variable Name</th>
<th>Return Type</th>
<th>Rule A</th>
</tr>
</thead>
<tbody>
{% for data in variable %}
<tr>
<td>{{ data.variable_name }}</td>
<td>{{ data.return_type }}</td>
<td>{{ data.rule_a }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
With 20k records I would recommend paging and/or serverside processing to improve performance.
@YOM I am using Django models to get data from sql database, I am not sure how to convert it into Ajax data?
Maybe this tutorial will help. The response should be JSON formatted:
https://simpleisbetterthancomplex.com/tutorial/2016/07/27/how-to-return-json-encoded-response.html
Datatables doesn't have Django server side code but you can find some third party Django apps for Datatables, like this:
https://pypi.org/project/django-datatables-view/
Looks like it supports server side process (paging) to return one page of data at a time. This will increase the render speed.
Kevin
If you did want to use one of the datatables serverside libraries, you could alternatively create an AWS Lambda function or host an apache server to handle server side processing outside of your Django app. It all depends on your implementation whether that's worth the effort.
This section of the FAQ should help, it discusses various techniques to improve performance,
Cheers,
Colin