Zählen Sie einfach die Ergebnisse der Unterabfrage...
SELECT COUNT(t.*) FROM
( (SELECT 1 AS sort_col,performerid,pic0
FROM $table
WHERE performerid IS NOT NULL
$performeridSql)
UNION
(SELECT 2 AS sort_col,performerid,pic0
FROM $table
WHERE performerid IS NOT NULL
$categorySql $buildSql
$breastsize $haircolor $age $ethnicity
$willingnessSql)
ORDER BY sort_col)
) AS t