30. Performance Optimization | Field Forge - Custom Fields, Built for Speed
Download Log in

30. Performance Optimization

Developer Guide

Field Forge is designed for performance from the ground up. Its custom table architecture and batch loading provide significant advantages over wp_postmeta-based solutions.

Custom Table vs PostMeta

Featurewp_postmeta (ACF)wp_fieldforge_values (Field Forge)
Query structureKey-value pairs, one row per fieldTyped rows with dedicated indexes
Compound fieldsFlattened: repeater_0_title, …Hierarchical: parent_id / row_index
Rows per repeater (10×5)50+ rows in postmeta11 rows in values table
Batch loadingN queries for N fields1 query for all fields per post
Cache integrationRelies on WordPress meta cacheBuilt-in Object Cache with fieldforge group

fieldforge_preload() for Custom Queries

php
$query = new WP_Query( [
    'post_type'      => 'product',
    'posts_per_page' => 20,
] );

// Preload all field values in ONE query
$post_ids = wp_list_pluck( $query->posts, 'ID' );
fieldforge_preload( $post_ids );

// Now get_field() calls use cached data -- zero additional queries
while ( $query->have_posts() ) : $query->the_post();
    $price = get_field( 'price' );    // From cache
    $image = get_field( 'thumbnail' ); // From cache
endwhile;
wp_reset_postdata();

Auto-Preload via the_posts

Field Forge automatically preloads values for posts in the main query. No extra code needed for standard archive pages, blog index, or search results.

Object Cache Integration

php
$stats = FIELDFORGE_Performance::instance()->get_stats();
/*
Returns:
[
    'total_values'    => 1523,
    'total_posts'     => 87,
    'total_groups'    => 5,
    'preloaded_posts' => 10,
    'object_cache'    => 'active',
    'cache_group'     => 'fieldforge',
]
*/

// Manual cache flush
FIELDFORGE_Performance::instance()->flush_all();

Forge AI Assistant Online

Hi! I'm the Field Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs