Index: src/wp-includes/media.php
===================================================================
--- src/wp-includes/media.php	(revision 28188)
+++ src/wp-includes/media.php	(working copy)
@@ -2695,16 +2695,6 @@
 		}
 	}
 
-	$audio = $video = 0;
-	$counts = (array) wp_count_attachments();
-	foreach ( $counts as $mime => $total ) {
-		if ( 0 === strpos( $mime, 'audio/' ) ) {
-			$audio += (int) $total;
-		} elseif ( 0 === strpos( $mime, 'video/' ) ) {
-			$video += (int) $total;
-		}
-	}
-
 	$settings = array(
 		'tabs'      => $tabs,
 		'tabUrl'    => add_query_arg( array( 'chromeless' => true ), admin_url('media-upload.php') ),
@@ -2719,8 +2709,8 @@
 		),
 		'defaultProps' => $props,
 		'attachmentCounts' => array(
-			'audio' => $audio,
-			'video' => $video
+			'audio' => wp_has_mime_type_attachments( 'audio' ) ? 1 : 0,
+			'video' => wp_has_mime_type_attachments( 'video' ) ? 1 : 0
 		),
 		'embedExts'    => $exts,
 		'embedMimes'   => $ext_mimes,
Index: src/wp-includes/post.php
===================================================================
--- src/wp-includes/post.php	(revision 28188)
+++ src/wp-includes/post.php	(working copy)
@@ -2292,6 +2292,23 @@
 }
 
 /**
+ * Determine if at least one attachment of a particular mime-type has been uploaded
+ *
+ * @global wpdb $wpdb
+ *
+ * @since 3.9.1
+ *
+ * @param string $mime_type The mime-type string to check.
+ *
+ * @return int|null If exist, the post ID of the first found attachment.
+ */
+function wp_has_mime_type_attachments( $mime_type ) {
+	global $wpdb;
+	$sql = sprintf( "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type LIKE '%s%%' LIMIT 1", like_escape( $mime_type ) );
+	return $wpdb->get_var( $sql );
+}
+
+/**
  * Get default post mime types
  *
  * @since 2.9.0
Index: tests/phpunit/tests/attachment/count.php
===================================================================
--- tests/phpunit/tests/attachment/count.php	(revision 0)
+++ tests/phpunit/tests/attachment/count.php	(working copy)
@@ -0,0 +1,25 @@
+<?php
+/**
+ * @group attachment
+ */
+class Tests_Attachment_Counts extends WP_UnitTestCase {
+
+	function test_wp_has_mime_type_attachments() {
+		$has = wp_has_mime_type_attachments( 'image' );
+		$this->assertEmpty( $has );
+
+		$this->factory->attachment->create_object( 'whatever/image.jpg', 0, array( 'post_mime_type' => 'image/jpeg' ) );
+		$has = wp_has_mime_type_attachments( 'image' );
+		$this->assertNotEmpty( $has );
+		$has = wp_has_mime_type_attachments( 'image/jpeg' );
+		$this->assertNotEmpty( $has );
+		$has = wp_has_mime_type_attachments( 'audio' );
+		$this->assertEmpty( $has );
+
+		$this->factory->attachment->create_object( 'whatever/audio.mp3', 0, array( 'post_mime_type' => 'audio/mpeg' ) );
+		$has = wp_has_mime_type_attachments( 'audio' );
+		$this->assertNotEmpty( $has );
+		$has = wp_has_mime_type_attachments( 'image' );
+		$this->assertNotEmpty( $has );
+	}
+}
\ No newline at end of file
