Fixing union slow queries