Combining database tables in server-side datatables

Combining database tables in server-side datatables

mitchypmitchyp Posts: 1Questions: 0Answers: 0
edited January 2013 in General
So, I am inheriting an intranet site that was built on datatables. Basically it is made in Wordpress and then displays custom fields that the users have filled out in the datatable. But it was querying 40 columns per post over 2k entries so is now grinding to a standstill when the users try and view the data in the table.

I'm attempting to utilize the server-side aspect of Datatables for this, but running into a little trouble because of how the sql data is formatted.

Can anyone offer any assistance in how to set up the server_processing.php file to:

1. Display rows based on the wp_posts.ID index
2. Display columns in this row based on a different table (wp_postmeta) wherein each column value is indexed separately in the wp_postmeta table by the ID found in 1
3. Link entire row to a url found in the wp_posts table

If anyone has any ideas I would really appreciate it, and if I can pay for support to this query let me know and I will gladly (I was just unsure if this was an avenue you do actually support). Thanks so much.

Replies

  • allanallan Posts: 63,389Questions: 1Answers: 10,450 Site admin
    What aspect of the loading at the moment is slow? Is it the retrieval of the data from the server, or the drawing of it in DataTables? If the latter, you can get a nice speed boost by Ajax loading the data (without the complexity of add server-side processing) and enabling deferred rendering ( bDeferRender ). That should have no problem drawing 2k rows.

    However, server-side processing is certainly a good option for large tables. It sounds like you want to do a join in the script - there is an example server-side processing script that does a join here: http://datatables.net/dev/server_processing.txt

    > 3. Link entire row to a url found in the wp_posts table

    Attach a jQuery 'click' event listener to the row which will use fnGetData on the row and then set window.location.href as required.

    Regards,
    Allan
This discussion has been closed.