WordPress media library pagination: where large libraries slow down

computer screen displaying website home page

Written by

in

The newsletter for newsletter operators

Daily field notes on deliverability, AI tools, hosting, and monetisation. No "top 10 plugins" filler — real tools, real numbers, real failures.

WordPress media library pagination: where large libraries slow down
Photo by Pankaj Patel on Unsplash

If you’ve been uploading images, PDFs, and video thumbnails to WordPress for more than a year, you’ve probably noticed the media library start to drag. The grid takes longer to load. Scrolling feels janky. Search stops returning results fast enough to be useful.

The problem isn’t your hosting—it’s how WordPress handles pagination when your media library grows past a few thousand files.

How WordPress loads the media library

When you open the media library, WordPress runs a database query to fetch attachments. By default, it returns 40 items per page in grid view, or as many as your screen size allows in list view. Each page load triggers a new query with an OFFSET clause that tells the database how many rows to skip before returning results.

For the first few pages, this works fine. But as your library grows—say, past 3,000 to 5,000 files—every query has to scan and skip thousands of rows before it can return the 40 you actually want to see. The database does more work, and load times climb.

WordPress core doesn’t index attachment queries by upload date or file type in a way that speeds up deep pagination. According to the WordPress Query class reference (checked November 2026), the WP_Query object used for media relies on the same posts table structure as everything else, and large offsets are expensive regardless of table size.

When it breaks

You’ll notice the slowdown around these thresholds:

  • 3,000–5,000 files: Grid view starts to lag when you scroll past page 10.
  • 10,000+ files: Searches take multiple seconds. Filtering by date or media type doesn’t help much because the query still scans the full table.
  • 25,000+ files: The media library becomes nearly unusable in the WordPress admin. Some hosting environments will time out before returning results.

The exact breaking point depends on your database server, PHP memory limit, and whether your host uses object caching. But the pattern holds: offset-based pagination doesn’t scale.

What to do about it

Use a media library plugin that indexes differently. Tools like Media Library Assistant (checked November 2026) let you filter and sort by custom taxonomies, which can bypass some of the worst query patterns. Others, like Enhanced Media Library (checked November 2026), add categories and MIME-type filters that rely on indexed joins instead of table scans.

Offload storage and serve files from a CDN or object storage service. This doesn’t fix pagination, but it does reduce the number of database rows WordPress has to manage. Plugins like WP Offload Media (checked November 2026) move your files to S3 or compatible services and leave only metadata in the WordPress database. Fewer rows means faster queries, even with large offsets.

Archive old media. If you have thousands of images from posts you published years ago, export them, back them up, and delete the attachments from WordPress. You can re-upload individual files if you ever need to update an old post. This is manual work, but it’s the fastest way to shrink your media library if you don’t need random access to every file you’ve ever uploaded.

Increase your per-page limit (carefully). Loading 100 or 200 items per page reduces the number of deep-offset queries you’ll trigger, but it also increases memory usage and can make the initial page load slower. Test this on a staging site before you push it to production. You can adjust the number in Screen Options at the top of the media library page.

One non-obvious tip

If you’re building a content site that publishes daily and embeds multiple images per post, budget for media-library maintenance from the start. Set a yearly reminder to audit and archive files, or commit to offloading storage before you hit 5,000 attachments. Fixing a slow media library after the fact is harder than preventing the problem in the first place.

Most solo operators don’t think about database query performance until it’s already a problem. Treat your media library like you treat your email list: clean it regularly, and don’t let it bloat.

Hit reply if you’ve found a better way to handle large WordPress media libraries—we’ll share the best answers in a future issue.

The newsletter for newsletter operators

Daily field notes on deliverability, AI tools, hosting, and monetisation. No "top 10 plugins" filler — real tools, real numbers, real failures.

Other newsletters you might like

Local Edinburgh

Local Edinburgh is a website that is dedicated to the promotion of Edinburgh as a travel destination. Edinburgh is Scotland’s capital city renowned for its heritage culture and festivals.

Subscribe

Ireland Moments

A daily newsletter and blog celebrating Ireland — its places, culture, music, history and the stories worth sharing from the Emerald Isle.

Subscribe

Love London

A newsletter for Londoners who want to rediscover their own city. Travellers planning their first or fifth visit. Anglophiles who fell in love with London through literature, film, or a rainy afternoon on the South Bank.

Subscribe

Scottish Rugby Fans

The best Scottish rugby updates, straight to your inbox — Six Nations, the Nations Championship, Glasgow and Edinburgh. Only when there's something worth reading.

Subscribe

Newsletters via the One Two Three Send network.  ·  Want your newsletter featured here? Click here