Time load page slow

Time load page slow

dasapadasapa Posts: 17Questions: 3Answers: 0
edited November 2012 in General
Hello,

sorry for my english language...i have a datatable page with 13560 rows. Problem is when i load the page, around 3-4 min and just with google chrome (IE and Firefox crash). I'm using serverside processing but i don't find difference when i use it. I show the code, if someone knows what i have to change or how can i solve this problem i will appreciate.

Code datatable

[code]
var oTable = $('#example').dataTable({

"sPaginationType": "full_numbers",
"bServerSide": true,
"sAjaxSource": "server_processing.php"

})


.columnFilter({sPlaceHolder: "head:after",
aoColumns: [
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},
{ type: "text"},

]
}) ;
[/code]

Code serverside processing

[code]
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/

/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','ab','bc','cd','de','ef','fg','gh','hi','ij','jk','kl','lm','mn','no','op','pq','qr','rs','tu','vn','vz');

/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "a";

/* DB table to use */
$sTable = "factura";

/* Database connection information */
$gaSql['user'] = "root";
$gaSql['password'] = "";
$gaSql['db'] = "contabilidad";
$gaSql['server'] = "localhost";




/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/

/*
* MySQL connection
*/
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );

mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );


/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}


/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);

while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
[/code]

[code] {"sEcho":1,"iTotalRecords":"4676","iTotalDisplayRecords":"4676","aaData":[["655"....]]} [/code]

Replies

  • allanallan Posts: 63,133Questions: 1Answers: 10,399 Site admin
    If you disable the column filter does that help? That's an unsupported third party plug-in. If that doesn't help. please link us to a test page, with column filter disabled, which shows the issue.

    Allan
  • dasapadasapa Posts: 17Questions: 3Answers: 0
    With column filter disabled is the same. I think the problem is when i enter the page ALL DATA is loaded. When load finish page shows only ten rows (ok), pagination run correctly, column filter ok. I dont know how i can load part of the data, for example in a datatable with 3519 rows show "iTotalDisplayRecords":"3519" - i think this is not ok.

    [code] {"sEcho":1,"iTotalRecords":"3519","iTotalDisplayRecords":"3519","aaData":[/code]

    I run the page localhost, i looking for link a test page.

    Thanks.
  • allanallan Posts: 63,133Questions: 1Answers: 10,399 Site admin
    With server-side processing enabled and fully implemented, it should only load the rows needed for the first draw (10 by default). This allows DataTables to work with millions of rows.

    See the server-side processing documentation here: http://datatables.net/usage/server-side

    Allan
  • allanallan Posts: 63,133Questions: 1Answers: 10,399 Site admin
    edited November 2012
    btw:

    > "iTotalDisplayRecords":"3519" - i think this is not ok.

    Its not - it shouldn't be a string.
  • dasapadasapa Posts: 17Questions: 3Answers: 0
    edited November 2012
    There is an array with data of ten rows, i think this is ok. I have been all day testing with diffetent server side proccesing method (jsonp) but always happens the same.

    I use datatable with Xampp and localhost, when i enter the page there is a message "trasferring data from localhost..." when the message dissapear datatable is loaded and run very good. I dont know if someone have used big tables with localhost, can be the long time used to load the page due to use localhost?
  • allanallan Posts: 63,133Questions: 1Answers: 10,399 Site admin
    10 row return is correct if DataTables asked for 10 rows.

    I use a 10 million row database on localhost and it runs within 300mS. So there shouldn't be an issue there.

    Allan
  • dasapadasapa Posts: 17Questions: 3Answers: 0
    thank you Allan...

    i solve the problem, it was a while {} inside the table, it loads all data in an array....i have been two weeks with this problem.

    Now i have other problem, i know is not a problem of datatable. Last column is an image to open an XML file tahn contains data of the row. In the row there is a column with a unique code, name of the file is this code.

    I have used jasonp with this code to insert static image:

    [code]$row[] = "";[/code]

    Function openxml require the name of the file (unique code, value of a column). I dont know how indicate this value.
  • allanallan Posts: 63,133Questions: 1Answers: 10,399 Site admin
    Two options:

    1. Modify the HTML you are generating to put the id in there. Since you are generating the HTML, I guess you can just put the id straight in there.

    2. Attach an event to the image which will read the data from the row and call the function as needed.

    Allan
  • dasapadasapa Posts: 17Questions: 3Answers: 0
    "Attach an event to the image will read the data..." . How can i make this? Is like the example down?

    http://datatables.net/release-datatables/examples/server_side/select_rows.html

    [code] /* Click event handler */ $('#example tbody tr').live('click', function () { var id = this.id; var index = jQuery.inArray(id, aSelected); if ( index === -1 ) { aSelected.push( id ); } else { aSelected.splice( index, 1 ); } $(this).toggleClass('row_selected'); } ); [/code]
  • allanallan Posts: 63,133Questions: 1Answers: 10,399 Site admin
    Yes, like that. Use fnGetData to get the data for the cell / row that was clicked.

    Allan
This discussion has been closed.