# Preloaders

> Eliminates N+1 SQL query problems on Magento 2 category, search, cart, and product pages by batch-loading product data during collection load

Eliminates N+1 SQL query problems across Magento 2 storefronts — category pages, search results, cart, and product detail pages — by batch-loading product data during collection load and serving it from memory during rendering.

## The Problem

When Magento renders a category page with 12 configurable products, it triggers **~160 SQL queries** taking **~850ms** of SQL time. Each product triggers individual queries for prices, stock status, tier prices, swatch options, super attributes, and catalog rules. This is the classic N+1 problem — and it gets worse with every product on the page.

## The Solution

Preloaders intercepts the product collection load and batch-loads all required data in a handful of queries. When Magento later requests data per-product during rendering, plugins return the preloaded data instead of hitting the database.

## Results

- **~160 queries → ~75 queries** for 60 products on a category page
- **~850ms SQL time → ~46ms** — over 18x faster database layer
- Works automatically — no code changes, no configuration

## Supported Product Types

Preloaders covers all major Magento product types out of the box:

- **Configurable** — prices, salable status, tier prices, swatches, super attributes
- **Bundle** — indexed prices, per-option salable status, option/selection data
- **Simple / Virtual / Downloadable** — tier prices, catalog rule prices
- **EAV / Attributes** — bulk attribute definitions, attribute option caching

## Requirements

- PHP 8.1, 8.2, 8.3, or 8.4
- Magento 2.4.x (Open Source, Adobe Commerce, MageOS)



<Admonition type="info" title="Interested?">
Detailed documentation, developer guides for building custom preloaders, and profiling tools are available to qoliber partners. Contact us at extensions@qoliber.com or request access through the portal.
</Admonition>
