Django: Datatables slow in production

Django: Datatables slow in production

Blackbull256Blackbull256 Posts: 4Questions: 2Answers: 0

Hey all,

I have incorporated datatables in my production application but it causes extremely long TTFB waiting times.

In total, the table only had 750 rows, and I don't think that such a low volume should cause these problems.. Does anyone know what could be the reason?

This is my code:

```$(document).ready(function() {

        $.fn.dataTable.moment('DD-MM-YYYY HH:mm');

        $('table.dezetabel').DataTable( {

            "language": {
                "lengthMenu": "Weergeef _MENU_ rijen per pagina",
                "zeroRecords": "Niks gevonden - sorry",
                "info": "Pagina _PAGE_ van _PAGES_, _TOTAL_ records" ,
                "infoEmpty": "Geen data beschikbaar",
                "infoFiltered": "uit _MAX_ records gefilterd)",
                "paginate": {
                    "first":      "Eerste",
                    "last":       "Laatste",
                    "next":       "Volgende",
                    "previous":   "Vorige"
                },
                "search":         "Zoeken:",


            },
            "lengthMenu": [[15, 20, 30, -1], [15, 20, 30, "Alles"]],

            "columnDefs": [ { 'type': 'date', 
                              'targets': [4]} ],
            "order": [[ 1, 'asc' ]],
            "dom": '<"top">rt<"bottom"lipB><"clear">',

            "responsive": true,
            "buttons": [
                        {
                            extend:    'copyHtml5',
                            text:      '<i class="fa fa-files-o"></i> copy',
                            titleAttr: 'Copy'
                        },
                        {
                            extend:    'excelHtml5',
                            text:      '<i class="fa fa-file-excel-o"></i> excel',
                            titleAttr: 'Excel'
                        },
                        {
                            extend:    'csvHtml5',
                            text:      '<i class="fa fa-file-text-o"></i> csv',
                            titleAttr: 'CSV'
                        },
                        {
                            extend:    'pdfHtml5',
                            text:      '<i class="fa fa-file-pdf-o"></i> pdf',
                            titleAttr: 'PDF'
                        }
                    ],
                } );


            } );````

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited January 2022

    This section of the FAQ should help, it discusses various techniques to improve performance. That said, 750 records should be fast, so it would be worth looking at the Django end of things.

    Cheers,

    Colin

Sign In or Register to comment.