Add gby optimization