diff --git a/extensions/redis/ActiveRecord.php b/extensions/redis/ActiveRecord.php
index 2913f86..38fabd7 100644
--- a/extensions/redis/ActiveRecord.php
+++ b/extensions/redis/ActiveRecord.php
@@ -233,20 +233,19 @@ class ActiveRecord extends BaseActiveRecord
      */
     public static function deleteAll($condition = null)
     {
+        $pks = self::fetchPks($condition);
+        if (empty($pks)) {
+            return 0;
+        }
+
         $db = static::getDb();
         $attributeKeys = [];
-        $pks = self::fetchPks($condition);
         $db->executeCommand('MULTI');
         foreach ($pks as $pk) {
             $pk = static::buildKey($pk);
             $db->executeCommand('LREM', [static::keyPrefix(), 0, $pk]);
             $attributeKeys[] = static::keyPrefix() . ':a:' . $pk;
         }
-        if (empty($attributeKeys)) {
-            $db->executeCommand('EXEC');
-
-            return 0;
-        }
         $db->executeCommand('DEL', $attributeKeys);
         $result = $db->executeCommand('EXEC');