Changes message sort clauses for MySQL, fixes issue #961.

This fixes the exception on stream polling with MySQL beckend.