I think on a generalization level, the bigger the fish species, the smarter they get.
Well, even among fish keepers, goldfish is considered as "mindless" somehow. They aren't exactly known for being smart among fish because they will eat their young, and they can't do certain tricks such as building a nest and guard the offspring like some other "smarter" fish species. In totally unsuitable environment created by newbie fish keepers, they will just swim around "mindlessly" until they die.
Actually goldfish has a memory span of 3 months. People did research with pond goldfish. They rang a bell before feeding them. After a while, every time they rang a bell they could gather all the goldfish even without fish food. The goldfish could remember it for up to 3 months if nobody ever ring a bell for that long.
I personally consider the fish who will protect their young as the smart fish. Goldfish isn't one of them.
While most cichlids, gourami, can do it. They take care of their offspring like pro. Gourami can even build nest with plant matters and their bubbles. You can see the video in the sticky.