Optimize HTML table load

0

I have an HTML table in a PHP project which is filled with data from MYSQL, the Select with which the table is filled, among other things, by 3 INNER JOIN, when executing the query from Workbenck this delay approximately 0.428 seconds in perform it but when entering the page that contains the HTML table it takes between 5 and 6 seconds to execute it which I think is a very high time since there are only 600 records.

The way I fill the table is by calling the getters I get from query, something like this:

<table>
       <?php foreach($consulta as $data): ?>
       <tr>
       <td><?php echo $data->getNombre() ?>
                                </td>
       <td><?php echo $data->getCiudad() ?>
       </td>
       <?php  endforeach; ?>
       </tr>
</table>
    
asked by wico 22.07.2018 в 15:14
source

1 answer

0

I can think of a couple of things that might help you:

  • Add the table-layout: fixed attribute to the table. Each time the browser renders a table it must calculate the dimensions of the content of each cell and adjust the complete table, with this attribute a fixed value is defined.

  • I see that you iterate an object and for each cycle of the array you have to call two methods, that is slower than directly printing the values of the array obtained by a fetch. For that case, you would have to make $ consult an array of the data you need using fetch (). I do not know if in your case it serves you.

                            

  • You could apply paging so you do not have to load all the data, if it does not affect what you want.

  • Try to make a table with infinite Scrolling, so that only the data is loaded as you go up or down the table. On this website there is an implementation of it: link

  • answered by 22.07.2018 в 16:46