vendredi 26 octobre 2018

Laravel - Fetching 1m+ rows and passing to vueJS

I've never had to fetch so much data before so I'm unsure how to go about this.

What I'm trying to do is fetch 1m+ records from a single table and display it using a vueJS front-end.

Obviously the table will be paginated but a search-box needs to be able to search through the table super quick.

I've looked into chunking but I'm not sure how to integrate this.

The following doesn't appear to be working...

The code that's commented out is taking 13 seconds when accessing the API direct and that's just 5000 rows.

public function getTransactionsV2() {

    // $transactions = DB::connection('mysql2')->select(DB::raw("SELECT * FROM transactionsV2 LIMIT 5000"));
    / $transactions = DB::connection('mysql2')->table('transactionsV2')->limit(5000)->get();

    DB::connection('mysql2')->table('transactionsV2')->orderBy('id')->limit(1000)->chunk(100, function ($transactions) {
        foreach ($transactions as $transactions) {
            return $transaction;
        }
    });

    // return $transactions;
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire