Slow when too many lines
Slow when too many lines
Hi,
i want to know if there is anything i can do on my code to speed up the table, when i get over 150 lines (9-10 columns) it gets very slow, usually taking between 6 to 10 seconds, and most of the time (on chrome) a window will popup saying the javascript is taking too long and if i wish to cancel it or wait.
my code is not server side because im using sqlite and i didnt found a way to do it.. (is there any?)
im building the table like this
[code]
foreach ($db->query("SELECT * FROM PROBLEMA WHERE LOTE_EXTERNO_ID_ASSOCIADO='$l_ext') as $row)
{
$tablecontents .= "
{$row['LOTE_EXTERNO_ID_ASSOCIADO']}
{$row['Numero_Placa']}
{$row['Defeito']}
{$row['Posicao']}
{$row['Reparo']}
{$row['Nota_Fiscal']}
{$row['Data']}
{$row['Responsavel']}
{$row['PROBLEMA_ID']}
" ;
}
echo $tablecontents;
}[/code]
thanks!!!
i want to know if there is anything i can do on my code to speed up the table, when i get over 150 lines (9-10 columns) it gets very slow, usually taking between 6 to 10 seconds, and most of the time (on chrome) a window will popup saying the javascript is taking too long and if i wish to cancel it or wait.
my code is not server side because im using sqlite and i didnt found a way to do it.. (is there any?)
im building the table like this
[code]
foreach ($db->query("SELECT * FROM PROBLEMA WHERE LOTE_EXTERNO_ID_ASSOCIADO='$l_ext') as $row)
{
$tablecontents .= "
{$row['LOTE_EXTERNO_ID_ASSOCIADO']}
{$row['Numero_Placa']}
{$row['Defeito']}
{$row['Posicao']}
{$row['Reparo']}
{$row['Nota_Fiscal']}
{$row['Data']}
{$row['Responsavel']}
{$row['PROBLEMA_ID']}
" ;
}
echo $tablecontents;
}[/code]
thanks!!!
This discussion has been closed.
Replies
Allan
here is a link to a 207 row table, it is taking a very long time to build it (just took me 20 seconds)
http://www.wi.com.br/wi04/defeitos.php?l_ext=117006661¬a=10179
if i cant fix this i will have to change all code to mysql, hope there is a solution to my problem..
thanks!
Allan
where do you think this infinite loop might be?
thanks for the help!
edit: link without datatables
http://www.wi.com.br/wi04/defeitos2.php?l_ext=117006661¬a=10179
Allan
this link has everything but the jeditable code
http://www.wi.com.br/wi04/defeitos2.php?l_ext=117006661¬a=10179
is there something wrong with my code?
thanks for the help allan
[code]
var user = "<?php echo $_COOKIE["nome_usuario"];?>";
if(user=='Cida' || user=='Kelly' || user=='Laura' || user=='Mary' || user=='Angela' || user=='Nayara' || user=='Diogo')
{
$('td:eq(1), td:eq(2), td:eq(3), td:eq(4), td:eq(5), td:eq(6), td:eq(7), td:eq(8)', oTable.fnGetNodes()).editable( 'update.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
$('.dataTables_scrollBody').scrollTo($(this));
},
"submitdata": function ( value, settings ) {
var aPos2 = oTable.fnGetPosition( this );
var aoColumns2 = oTable.fnSettings().aoColumns;
var hValue2 = aoColumns2[aPos2[1]].sTitle;
var id2 = oTable.fnGetData( aPos2[0] );
return {
"row_id": this.parentNode.getAttribute('id'),
"column": oTable.fnGetPosition( this )[2],
"value2": hValue2,
"id2": id2[9],
"id": 'PROBLEMA_ID' ,
"tab": 'PROBLEMA'
};
},
"height": "20px",
"event" : "dblclick",
"tooltip" : "Clique 2 vezes para editar..."
} );
}[/code]
[code]
$('td:eq(1), td:eq(2), td:eq(3), td:eq(4), td:eq(5), td:eq(6), td:eq(7), td:eq(8)', oTable.fnGetNodes())
[/code]
If you replace it with:
[code]
$('td', oTable.fnGetNodes())
[/code]
Is it faster? Obviously not what you want - but a good test. Perhaps
[code]
$('td:lt(9)', oTable.fnGetNodes())
[/code]
would be faster, while doing what is needed?
Allan
and
$('td:lt(9)', oTable.fnGetNodes())
are way faster..
but how do i use the selector if i want to edit columns 3, 6 and 8 for example?
thanks a lot for the help Allan!
Allan
i hope i can find an answer to get individual columns, i just noticed that my code to walk between rows with the cursor gets slow on big tables too, probably for the same reason (using eq selector).