Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

Slow loading table

$
0
0

I have a products table and one customer is taking between 10-20 seconds to load with only 4,000 records.

Here is my PHP. The products table has indexes on productid and customerid. I'm passing the customerid in the where clause.

<?php
session_start();

$thisCustomerid = $_SESSION['customerid'];

/*
 * Editor server script for DB table table_products
 * Created by http://editor.datatables.net/generator
 */

// DataTables PHP library and database connection
include( "lib/DataTables.php" );

// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Join,
    DataTables\Editor\Validate;


// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'table_products', 'id' )
    ->fields(
        Field::inst( 'table_products.id' ),
        Field::inst( 'table_products.productid' )
            ->validator( 'Validate::notEmpty' )
            ->validator( 'Validate::unique' ),
        Field::inst( 'table_products.lotnumber' ),
        Field::inst( 'table_products.manufacturedate' ),
        Field::inst( 'table_products.expirydate' ),
        Field::inst( 'table_products.productname' ),
        Field::inst( 'table_products.description' )
            ->validator( 'Validate::notEmpty' ),
        Field::inst( 'table_products.grouping' ),
        Field::inst( 'table_products.stockwarning' )
        ->validator( 'Validate::notEmpty', array(
        "message"  => "Please provide a number (0 minimum)" ) ),
        Field::inst( 'table_products.equipment' ),
        Field::inst( 'table_products.miscellaneous' ),
        Field::inst( 'table_products.notes' ),
        Field::inst( 'table_products.unitcost' )
        ->validator( 'Validate::notEmpty', array(
        "message"  => "Please provide a number (0 minimum)" ) ),
        Field::inst( 'table_products.unitmeasurement' ),
        Field::inst( 'table_products.active' )  
            ->options( 'table_active', 'id', 'active' ),
        Field::inst( 'table_products.customerid' )
            ->setValue($thisCustomerid),
        Field::inst( 'table_products.upc_code' )
    )
    ->where( 'table_products.customerid', $thisCustomerid )
    ->leftJoin( 'table_active', 'table_active.id', '=', 'table_products.active' )   
    ->process( $_POST )
    ->json();

Viewing all articles
Browse latest Browse all 2364

Trending Articles