Where a Fish gets its oxygen?

Fish use their gills to filter oxygen from the water. However, if the water is stagnant enough they are unable to get oxygen and suffocate(this is why most fish can't live in puddles or small ponds). Some fish have a labyrinth organ that basically acts as a human lung, so they can breathe both air and underwater and don't have to worry about this(such as betta fish).