MySQL select union which way is better

Program tries to find the maximum id in two tables.

I rewrote it as:

    MAX(id) +1
    (SELECT MAX(id) AS id   
     FROM `order_wholesale` 
     SELECT MAX(id) AS id 
     FROM `order`
    ) AS m

Before my intrusion it looked like

public static function getNextId()
    $commander = Yii::app()->db;

    foreach (self::TABLES as $elem)

        $res = $commander->createCommand('SELECT id FROM `' . $elem . '` ORDER BY ID DESC LIMIT 1')->queryRow();

        if ($res && isset($res['id']))
            $id_pks[] = $res['id'];

    if (!count($id_pks))
        return 1;

    return max($id_pks) + 1;

So per se it queried each table separately and decision which to pick was did on programming language above MySQL.

Doing it single query using UNION should be faster isn’t it?

MySQL’s explain shows this:

It says that 2,3 queries were “optimised away”.

I can’t figure out whether optimisation was used or not