Skip to content

Instantly share code, notes, and snippets.

View bsmaha's full-sized avatar

Bohdan Smaha bsmaha

  • Regent University
  • Virginia Beach, VA
View GitHub Profile
@bsmaha
bsmaha / gist:6468d53c16a23796f8af95f98bdf49f1
Created October 8, 2024 15:24
Fix for GP Entry Blocks Slow Query
add_filter('gpeb_filters_col_rows_query', 'custom_optimize_gf_entry_meta_query_with_cache', 10, 3);
function custom_optimize_gf_entry_meta_query_with_cache($sql, $col, $table) {
// Check if the current table and column are the ones we want to optimize
if ($table === GFFormsModel::get_entry_meta_table_name() && $col === 'meta_key') {
// Attempt to retrieve cached meta_key results
$cached_meta_keys = get_transient('gf_entry_meta_keys');
// If the cache exists, skip running the query
if ($cached_meta_keys !== false) {