Understanding the data source

Understanding the data source

EnngageEnngage Posts: 5Questions: 0Answers: 0
edited February 2014 in General
Hi,

I'm very interested in this plugin as it seems really great for my purposes. However I would like to clarify some things which I wasn't able to find in the documentation.

This may sound like a 'newbie' question, however I would like to ask what data source should I use if I get say 1000 rows? Using DOM to generate all records seems to be quite inefficient to me. Till now I have generated only a certain amount of rows with limiting the sql query. What is the best way to handle this?

Is http://datatables.net/release-datatables/examples/data_sources/ajax.html this what should I use?

I might be missing something, any help will be greatly appreciated.

Replies

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    As you are already using a database, I would just continue with your current procedures. 1000 rows is not a particularly large table.
    If you do get a problem with performance, read up on server-side processing:
    http://datatables.net/release-datatables/examples/data_sources/server_side.html
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    DOM sourced data or Ajax sourced data with client-side processing sound like the correct approaches to me for 1000 rows. Server-side processing should only really come into play when working with tens of thousands of rows.

    Allan
  • EnngageEnngage Posts: 5Questions: 0Answers: 0
    Hi Allan,

    Thanks for the prompt response.

    So to clarify it you dont think that generating 1000 table rows on a single html page is too many? I always limited this number so that the load time is quick.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    There are so many variables that I can't give you a "yes / no" answer. For example, on a localhost server with good hardware, 1000 rows is trivial. But if you are on a mobile phone with 2K/s downlink, it might not be acceptable...

    On balance, for me, 1000 records in the DOM is okay, but it really depends upon your use case and target market.

    Allan
  • EnngageEnngage Posts: 5Questions: 0Answers: 0
    edited February 2014
    Hi,

    Thank you again for for response.

    I have now implemented the data tables according to my needs. However I'm still little struggling with that thousands of rows being rendered on the page. Never done this before and always considered it as a too "heavy weight" when I could only need a couple of rows. Seems like wasting the bandwith. Can you take a look at an example I just put up at http://enn.9e.cz/cms/test2.php? Its a really large amount of DOM Data, at least to me:).

    I'm considering on implementing this in my CMS, so only editors would have access to these tables, which could mean that the bandwith will be ok for this purpose. One more question for now - what would you "generally" say is the limit of generating rows to the DOM ?

    Thank you again for your assistance.
  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    You speak of "thousands of rows being rendered" but your example has less than 1000. Then you say you might only need a couple of rows - in which case surely you would modify your request to your data source?
    I don't understand why you don't simply run tests for as much or as little data as may be required, and review performance accordingly. You are the only person using your configuration of hard- and software; anyone else can only speculate.
  • EnngageEnngage Posts: 5Questions: 0Answers: 0
    edited February 2014
    Hi,

    Thanks for the response.

    As you said, its just an example. I can easily generate much more. But even this seems too much to me.

    If I modify the data source so that I will get say 100 rows, I wont be able to sort all of them and more importantly the pagination of DataTable wont work because it wont simply know the rows are there..
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > One more question for now - what would you "generally" say is the limit of generating rows to the DOM ?

    See http://datatables.net/faqs#speed .

    However, it is basically up to yourself. If you don't want to transmit the full set of rows - use server-side processing that @tangerine mentioned, which will get only the rows needed for the current display.

    Allan
This discussion has been closed.