Automattic / Automattic/markdown-database-integration

Smart resolution skipping — skip file reads for metadata-only queries

Open
#45 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
PHP
Stars
5
Forks
1
Avg merge
2h 38m
Merged PRs (30d)
155

Description

## Problem

Currently, `resolve_content()` fires for every SELECT on wp_posts that includes `post_content` (which is most queries, since WordPress uses `SELECT *`). This means even admin list tables and count queries trigger file reads, even though they don't display content.

## Proposed solution

Phase 4 of the Index/Map Architecture:

1. **Detect metadata-only queries**: queries where content is selected but never used (admin list tables, REST collection endpoints with `_fields`, WP_Query with `fields => 'ids'`)
2. **Use the `posts_fields` filter**: WordPress fires this filter on WP_Query — we can detect when content is excluded
3. **Lazy-lazy resolution**: instead of resolving content in `query()`, resolve it in `the_content` filter or when `$post->post_content` is first accessed

## Impact
Low priority — file reads are ~0.1ms each. For a listing page with 20 posts, that's 2ms total. But for admin pages with 100+ posts, it adds up.

## Context
Phase 4 of the Index/Map Architecture (PR #41).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.