Loading data into datatable from database

Hi. I want to load about 100,000 rows from a database into a data table. it is possible to transfer data in parts of 30,000 rows (if more, then the error exceeds the limit). my code is:
var amountSKU = 30000;
var pos = 0;
$$("artsku").loadNext(10000, pos, function () {
pos += 10000;
"/api/?id=GetSliceArtSKUdate&amountSKU=" + amountSKU );
The server returns $ wpdb-> get_results ('SELECT * FROM MY_TABLE LIMIT 30000') 30000rows and all these rows are added to the datatable of 10,000 rows (everything is OK). but how do I load the rest of the rows?


  • edited August 2019

    Hey @kirilldonenko, could you please provide more details about your data loading implementation? Provided everything is set up right on your side, and the server response returns correct parameters the load/url should handle 100k entries, since they will be loaded dynamically, and not all at once. Additionaly, you can also use load/loadNext to load a specific amount of entries (i.e. in the case of loadNext it would be something like $$("grida").loadNext(30000,0,null,"data/data.php")). Is there a particular reason you can't/don't want to use this feature?

  • edited August 2019

    Thanks for the quick response. First, I have a request to the server - how many records will be received from the database. When I specify more than 30,000 lines in a request (for example, 50,000), I get an error 500 (Internal Server Error)
    Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 47255552 bytes) in /var/www/html/cands.app/wp-content/themes/appcands/api/art.php on line 340

  • The problem is that I can not do a few - $$ ("grida"). LoadNext (30000,0, null, "data / data.php") - synchronously.

  • this is the code on the server
    $res = $wpdb->get_results('SELECT * FROM MY_TABLE LIMIT 30000');
    echo json_encode($res);

  • in Docs:
    Sample of JSON response
    how can I add parameters - "pos": 0,
         "total_count": 999?

  • As you've already correctly noted, you can't do a few load/loadNext synchronously in a row, in this case you'll have to wait for the promise and load the next chunk after it's resolved. Here's an approximate solution using load: https://snippet.webix.com/671pimns.

    In this example count and pos will be 30000 for you respectively, you'll also have to adjust the total count to exit the recursion when needed.

    As for the server-side response parameters i'm pretty sure you'll have to form additional SQL requests, i.e. something like

    SELECT COUNT(id) AS pos FROM table WHERE id <= current_id

    but I can't really help you with a concrete example there.

  • I think it should work. thank you very much

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!