I'm using the queue manager to manage my API calls to Amazon. So I'm queueing up 10 SKUs at a time for each job. However, I ran into a hard limit of MySQL and PDO, I think I recall seeing it's something like 65k rows (don't quote me :) I have 85k products in my Product model's table right now.
That said, I'm using the below code to query on my main model, Product, based on the ProductDetails model which stores some data I need to find the right SKU, which belongs to the Product model.
I plan to have millions of products in my database and I want to get the prices updated every day, so I'll have to queue up these products everyday.
Here's the error I ran into:
Based on what I've read for similar issues, I think I need to chunk the results from Eloquent -- probably in batches of 60k -- and then run the foreach to chunk those into jobs, but I tried chunking the eloquent results and no go.
Here is my working code before the volume of products.
public function handle()
{
$start = microtime(true);
$builder = ProductDetail::with('product')
->where('vendor_id','1');
$productDetails = $builder->get();
echo "\n".$builder->count() . " products added.\n\n";
echo $builder->toSql()."\n\n";
$products = $productDetails->map(function($p){
return $p->product;
})->chunk(config('services.amazonapi.max_results'));
$now = \Carbon\Carbon::now();
foreach($products as $chunk){
AmazonProductLookup::dispatch($chunk)->onQueue('amazon_product_lookups')->delay($now->addSecond());
}
$end = microtime(true);
$this->info("Took ".($end - $start) ." seconds to complete\n");
}
Any help is GREATLY appreciated, TIA!