What is Chunk and Cursor?
Chunk: It will “paginate” your query, this way you use less memory.
* Uses less memory
* It takes longer
public function getData() {
Contact::chunk(1000, function ($contacts) {
foreach ($contacts as $contact) {
//rest of your code...
}
});
}
Cursor: You will use PHP Generators to search your query items one by one.
* It takes less time
* Uses more memory
public function getData() {
foreach (Contact::cursor() as $contact) {
//rest of your code...
}
}
Monday, 11 January 2021
What is Chunk and Cursor?
Subscribe to:
Post Comments (Atom)
Machine Learning - Potato Leaf Disease Prediction
Step 1: import numpy as np import pandas as pd import splitfolders import matplotlib.pyplot as plt import tensorflow as tf from tensorflow i...
-
Step1: composer create-project laravel/laravel canpac Step2: cd canpac Step3: composer require laravel/ui Step4: php artisan ui bootst...
-
1. Create a middleware name PostShortCodeMiddleware 2. Add this middleware in the kernal file. 3. Create a shortcode.php and shorcodeurl.php...
No comments:
Post a Comment