Postgresql Window Functions Performance Task