#I'm using Laravel Excel to handle exports and imports with more than 300K records, but I'm facing me

7 messages · Page 1 of 1 (latest)

faint jolt
#

Hello everyone! I'm using Laravel Excel to handle exports and imports with more than 300K records, but I'm facing memory usage and timeout issues. I'm already using queued exports, but large datasets still cause problems. What are the best practices to optimize performance and prevent memory exhaustion? thank you!

high notch
faint jolt
#

Really Appreciate Sir!! and is the same as export?

high notch
faint jolt
#

Sorry for the late Sir, I was already using chunks "public function chunkSize(): int
{
return 5000;
}" ```php class StudentExport implements FromQuery, ShouldAutoSize, ShouldQueue, WithChunkReading, WithColumnWidths, WithHeadings, WithStyles
{
use Exportable;

public function query()
{
    return Employee::select('full_name','emp_id');
}

public function headings(): array
{
    return [
        'Full Name',
        'Employee ID',
    ];
}

public function columnWidths(): array
{
    return [
        'A' => 30,
        'B' => 30,
    ];
}

public function styles(Worksheet $sheet)
{
    return [
        1 => [
            'font' => ['bold' => true],
        ],
        'C' => ['alignment' => ['horizontal' => 'center']],
    ];
}

public function chunkSize(): int
{
    return 5000;
}

}```

bronze trench
faint jolt
#

let me check again! thanks a lot Sir