Skip to content

Commit

Permalink
Improve slow queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Jan 23, 2025
1 parent bb9461c commit 4485594
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 9 additions & 4 deletions classes/Bulk/WP.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,15 @@ public function get_optimized_media_ids_without_format( $format ) {
}
$mime_types = str_replace( ",'" . $mime . "'", '', $mime_types );
$statuses = Imagify_DB::get_post_statuses();
$nodata_join = Imagify_DB::get_required_wp_metadata_join_clause();
$nodata_where = Imagify_DB::get_required_wp_metadata_where_clause( [
'prepared' => true,
] );
$nodata_join = '';
$nodata_where = '';
if ( ! imagify_has_attachments_without_required_metadata() ) {
$nodata_join = Imagify_DB::get_required_wp_metadata_join_clause();
$nodata_where = Imagify_DB::get_required_wp_metadata_where_clause( [
'prepared' => true,
] );
}

$nextgen_suffix = constant( imagify_get_optimization_process_class_name( 'wp' ) . '::' . strtoupper( $format ) . '_SUFFIX' );

$ids = $wpdb->get_col( $wpdb->prepare( // WPCS: unprepared SQL ok.
Expand Down
8 changes: 6 additions & 2 deletions inc/functions/admin-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,12 @@ function imagify_count_saving_data( $key = '' ) {

$mime_types = Imagify_DB::get_mime_types();
$statuses = Imagify_DB::get_post_statuses();
$nodata_join = Imagify_DB::get_required_wp_metadata_join_clause();
$nodata_where = Imagify_DB::get_required_wp_metadata_where_clause();
$nodata_join = '';
$nodata_where = '';
if ( ! imagify_has_attachments_without_required_metadata() ) {
$nodata_join = Imagify_DB::get_required_wp_metadata_join_clause();
$nodata_where = Imagify_DB::get_required_wp_metadata_where_clause();
}
$attachment_ids = $wpdb->get_col( // WPCS: unprepared SQL ok.
"
SELECT p.ID
Expand Down

0 comments on commit 4485594

Please sign in to comment.