Hybrid EnginePRO

Docs Modules Performance Mode Hybrid Engine

#Introduction

The Hybrid Engine compress all field meta references (field_abcdef123456) and effectively cut in half Posts, Terms, Users & Options pages metadata. Based on years of experience with the Ultra Engine (formerly known as Single Meta), this alternative solution combines the best of both worlds.

It makes ACF on par with the native WordPress meta logic, without sacrificing any ACF feature, while maintaining compatibility with WP_Query and search plugins out-of-the box.

#Hybrid Engine Meta Structure

ACF Extended
Howdy, ACF Extended
Edit PageAdd New
WP Custom Fields 2
NameValue
_edit_lock
1611654170:1
_acf
Array
(
    [_my_field] => field_5ffd218f27704
    [_my_content] => field_5ffd218f27704
    [_my_date] => field_5ffd27b80a8af
)
a:3:{s:9:"_my_field";s:19:"field_5ffd218f27704";s:11:"_my_content";s:19:"field_5ffd218f27704";s:8:"_my_date";s:19:"field_5ffd27b80a8af";}
ACF Custom Fields 3
NameValueField Group
my_field
Vestibulum ac diam sit amet
My Field Group
my_content
Curabitur placerat non leo
My Field Group
my_date
20210831
My Field Group
Publish
ID: 412
Type: Page
Status: Published
Visibility: Public
Object data: View
Meta count: 5 Clean
Performance Mode
Engine: Hybrid
Status: Active

#Native ACF Meta Structure

ACF Extended
Howdy, ACF Extended
Edit PageAdd New
WP Custom Fields 1
NameValue
_edit_lock
1611654170:1
ACF Custom Fields 6
NameValueField Group
_my_field
field_5ffd218f27704
My Field Group
my_field
Vestibulum ac diam sit amet
My Field Group
_my_content
field_5ffd218f27704
My Field Group
my_content
Curabitur placerat non leo
My Field Group
_my_date
field_5ffd27b80a8af
My Field Group
my_date
20210831
My Field Group
Publish
ID: 412
Type: Page
Status: Published
Visibility: Public
Object data: View
Meta count: 7 Clean
Author

#Preamble

Due to the complex nature of metadata, the Performance Mode might be difficult to assimilate at first sight. This is why it is strongly recommended to backup your website and test it on a development environment first, to understand the ins and outs before going live.

#Enable Module

The Performance Mode is disabled by default. It can be enabled and disabled in the Settings UIPRO, or with the following code:

#Using acf/init

add_action('acf/init', 'my_acfe_modules');
function my_acfe_modules(){

    // enable performance mode with hybrid engine
    acf_update_setting('acfe/modules/performance', 'hybrid');
    
}

#Using acfe/init

add_action('acfe/init', 'my_acfe_modules');
function my_acfe_modules(){
    
    // enable performance mode with hybrid engine
    acfe_update_setting('modules/performance', 'hybrid');
    
}

#Configure Engine

The Hybrid Engine can be configured using the acfe/modules/performance/config hook. Usage example:

/**
 * acfe/modules/performance/config
 *
 * @param $config
 *
 * $default_config = array(
 *     'engine'     => 'ultra',      // ultra (default) | hybrid
 *     'mode'       => 'production', // test | production (default) | rollback
 *     'ui'         => false,        // display metabox (dev mode should be enabled)
 *     'post_types' => array(),      // allowed post types (all)
 *     'taxonomies' => array(),      // allowed taxonomies (all)
 *     'users'      => false,        // allowed user roles (none)
 *     'options'    => false,        // allowed option id  (none)
 * );
 */
add_filter('acfe/modules/performance/config', 'my_acfe_performance_config');
function my_acfe_performance_config($config){
    
    // define config
    $config['engine'] = 'hybrid';
    $config['ui']     = true;
    $config['mode']   = 'test';
    
    // return
    return $config;
    
}

You can also directly pass the $config array in the setting instead:

add_action('acfe/init', 'my_acfe_modules');
function my_acfe_modules(){
    
    // enable performance mode with config
    acfe_update_setting('modules/performance', array(
        'engine' => 'hybrid',
        'ui'     => true,
        'mode'   => 'test',
    ));
    
}

#Engine Modes

#Test-Drive Mode

The Test-Drive Mode allows you to try the feature without touching normal ACF meta. This mode is a safe bet if you want to take a look at the process and make sure everything runs fine.

#Production Mode

The Production Mode is the default mode. It will compress all meta references into a single row and delete ACF normal meta references in the process to fully deploy its speed capacity.

#Rollback Mode

The Rollback Mode allows you to rollback to the normal ACF mode, and remove any Hybrid Engine related meta in the process.

#Getting Started

It is highly recommended to enable the Developer Mode to have a better view of Post/Taxonomies/Users/Options Pages metadata. Additionally, using the Performance Metabox will help you to switch modes on-demand.

This section will assume you use the “Hybrid Engine” in “Test-Drive Mode”, with the following configuration:

add_action('acfe/init', 'my_acfe_modules');
function my_acfe_modules(){
    
    acfe_update_setting('modules/performance', array(
        'engine' => 'hybrid', // use hybrid engine
        'ui'     => true,     // display metabox (dev mode should be enabled)
        'mode'   => 'test',   // use test-drive mode
    ));
    
}

#I just enabled the module. What now?

Nothing. All posts metadata remain the same. Any ACF related functions such as get_field(), have_rows(), update_field() keep working just like before.

Head over a Post Edit screen, you should see your metadata as usual:

_my_field = field_5ffd218f27704
 my_field = Vestibulum ac diam sit amet
_my_date  = field_5ffd27b80a8af
 my_date  = 20210831

The conversion process begins each time you save a post. Click on the “Update” button to save your post. You should now see a new _acf metadata with meta references compressed into an array:

_acf = array(
    [_my_field] => field_5ffd218f27704
    [_my_date]  => field_5ffd27b80a8af
)

From now on, ACF will load/save meta references into that _acf meta array seamlessly. Any ACF related functions such as get_field(), have_rows(), update_field() keep working just like before.

#I still see the normal meta references. Is this normal?

Yes. This is a safeguard logic of the “Test-Drive Mode”, which keeps a copy of your normal meta references. This allows you to test the feature safely. If anything unusual happen, you can always disable the Performance Mode. Everything will return back to the normal state, like if nothing happened.

#That’s it? Am I good to go?

Not yet. Normal meta references will continue to weigh on the loading of your database. In order to deploy the full performance capacity of the Hybrid Engine you have to enable the “Production Mode”, which will remove the normal meta references during the saving process.

Non-converted posts will keep working as usual. See the point “I just enabled the module. What now?

#This manual process feels tedious. What if I have thousands of posts?

Once you have assimilated all the notions mentioned above, you can head over the Scripts UIPRO to mass convert your posts using the Performance Mode Converter script.

#How can I rollback to the normal ACF meta?

To rollback, and cleanup Hybrid Engine related meta, simply switch to the “Rollback Mode” and update the post again. Everything will return to the normal state.