system/Database/BaseUtils.php
public function optimizeDatabase()
	{
		if ($this->optimizeTable === false)
		{
			if ($this->db->DBDebug)
			{
				throw new DatabaseException('Unsupported feature of the database platform you are using.');
			}
			return false;
		}

		$result = [];
		foreach ($this->db->listTables() as $table_name)
		{
			$res = $this->db->query(sprintf($this->optimizeTable, $this->db->escapeIdentifiers($table_name)));
			if (is_bool($res))
			{
				return $res;
			}

			// Build the result array...

			$res  = $res->getResultArray();

			// Postgre & SQLite3 returns empty array
			if (empty($res))
			{
				$key = $table_name;
			}
			else
			{
				$res  = current($res);
				$key = str_replace($this->db->database . '.', '', current($res));
				$keys = array_keys($res);
				unset($res[$keys[0]]);
			}

			$result[$key] = $res;
		}

		return $result;
	}
public function optimizeDatabase()
	{
		if ($this->optimizeTable === false)
		{
			if ($this->db->DBDebug)
			{
				throw new DatabaseException('Unsupported feature of the database platform you are using.');
			}
			return false;
		}

		$result = [];
		foreach ($this->db->listTables() as $table_name)
		{
			$res = $this->db->query(sprintf($this->optimizeTable, $this->db->escapeIdentifiers($table_name)));
			if (is_bool($res))
			{
				return $res;
			}

			// Build the result array...

			$res  = $res->getResultArray();

			// Postgre & SQLite3 returns empty array
			if (empty($res))
			{
				$key = $table_name;
			}
			else
			{
				$res  = current($res);
				$key = str_replace($this->db->database . '.', '', current($res));
				$keys = array_keys($res);
				unset($res[$keys[0]]);
			}

			$result[$key] = $res;
		}

		return $result;
	}
Optimize Database

@return mixed
@throws \CodeIgniter\Database\Exceptions\DatabaseException