$wgDBmwschema identifies the PG or MSSQL schema in the database. It's functionally equivalent to $wgDBprefix, in that it allows multiple wiki instances to co-exist in the same database. This means that wfWikiID() should include $wgDBmwschema if set for the same reason it includes $wgDBprefix: cache keys for different wikis in the same database need to be distinct.
Note that schema and prefix need to be encoded so wfSplitWikiID() can distinguish them.