Index: src/wp-admin/includes/template-functions.php
===================================================================
--- src/wp-admin/includes/template-functions.php	(revision 35708)
+++ src/wp-admin/includes/template-functions.php	(working copy)
@@ -577,21 +577,34 @@
 	$post = get_post( $post );
 
 	/**
-	 * Filter the number of custom fields to retrieve for the drop-down
-	 * in the Custom Fields meta box.
+	 * Filter any pre-defined post meta keys for the Custom Fields meta box
+	 * to short circuit a range query agaisnt postmeta.
 	 *
-	 * @since 2.1.0
+     * @since 4.4.0
 	 *
-	 * @param int $limit Number of custom fields to retrieve. Default 30.
-	 */
-	$limit = apply_filters( 'postmeta_form_limit', 30 );
-	$sql = "SELECT DISTINCT meta_key
-		FROM $wpdb->postmeta
-		WHERE meta_key NOT BETWEEN '_' AND '_z'
-		HAVING meta_key NOT LIKE %s
-		ORDER BY meta_key
-		LIMIT %d";
-	$keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
+	 * @param array $keys Pre-defined meta keys to be used in place of a postmeta query. Default array().
+     */
+	$keys = apply_filters( 'postmeta_form_keys', array() );
+
+	if ( empty( $keys ) ) {
+		/**
+		 * Filter the number of custom fields to retrieve for the drop-down
+		 * in the Custom Fields meta box.
+		 *
+		 * @since 2.1.0
+		 *
+		 * @param int $limit Number of custom fields to retrieve. Default 30.
+		 */
+		$limit = apply_filters( 'postmeta_form_limit', 30 );
+		$sql = "SELECT DISTINCT meta_key
+			FROM $wpdb->postmeta
+			WHERE meta_key NOT BETWEEN '_' AND '_z'
+			HAVING meta_key NOT LIKE %s
+			ORDER BY meta_key
+			LIMIT %d";
+		$keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
+	}
+
 	if ( $keys ) {
 		natcasesort( $keys );
 		$meta_key_input_id = 'metakeyselect';
