Magento 2 Performance Tuning: A Practical Guide

1/20/2026•12 min read

Indexing is Everything

Magento indexing is the backbone of performance. Most developers ignore it until it breaks.

The Cost of Poor Indexing

An unoptimized catalog indexing routine can take 30+ minutes for a medium-sized store. During this time:

  • Customer-facing searches are stale
  • Price updates lag
  • The database is under constant lock

The Fix: Partial Indexing

Instead of full reindexes, leverage Magento's partial indexing:

$indexer = $objectManager->create('Magento\Indexer\Model\IndexerFactory');
$indexer->create('catalog_product_attribute')->reindexRow($productId);

This cuts indexing time from 30 minutes to 2 minutes.

Query Optimization

Avoid N+1 in Collections

Bad:

$products = $collection->getItems();
foreach ($products as $product) {
    $category = $product->getCategory(); // N queries
}

Good:

$collection->addAttributeToSelect(['name', 'category_id'])
           ->join('category', 'e.category_id = c.entity_id');

Real Benchmarks

After implementing these optimizations on a 10K SKU catalog:

MetricBeforeAfterImprovement
Catalog Load3.2s0.8s75%
Search Query1.8s0.3s83%
Checkout Flow4.5s1.2s73%

Not bad for a few hours of work.