Re: I can't wait too much: Total runtime 432478.44 msec - Mailing list pgsql-performance

From Fernando Papa
Subject Re: I can't wait too much: Total runtime 432478.44 msec
Date
Msg-id F1DC5B511E2D1C499E5E20FC6D74160D03A04E58@exch2000.buehuergo.corp.claxson.com
Whole thread Raw
In response to I can't wait too much: Total runtime 432478.44 msec  ("Fernando Papa" <fpapa@claxson.com>)
List pgsql-performance
Sorry Chris... a little slower...

esdc=> EXPLAIN ANALYZE
SELECT
  cont_contenido.id_contenido
 ,cont_contenido.pertenece_premium
 ,cont_contenido.Titulo_esp as v_sufix
 ,cont_contenido.url_contenido
 ,cont_contenido.tipo_acceso
 ,cont_contenido.id_sbc
 ,cont_contenido.cant_vistos
 ,cont_contenido.cant_votos
 ,cont_contenido.puntaje_total
 ,cont_contenido.id_contenido_padre
 ,juegos_config.imagen_tapa_especial
 ,juegos_config.info_general_esp as info_general
 ,juegos_config.ayuda
 ,juegos_config.tips_tricks_esp as tips_tricks
 ,juegos_config.mod_imagen_tapa_especial
 ,cont_publicacion.fecha_publicacion as fecha_publicacion
 ,cont_publicacion.generar_Vainilla
FROM
 cont_contenido
 ,juegos_config
 ,cont_publicacion
WHERE
 cont_contenido.id_instalacion        = 2
 AND cont_contenido.id_sbc           = 619
 AND cont_contenido.id_tipo           = 2
 AND cont_contenido.id_instalacion  = juegos_config.id_instalacion
 AND cont_contenido.id_contenido   = juegos_config.id_contenido
 AND upper(cont_publicacion.generar_Vainilla) = 'S'
 AND cont_publicacion.id_instalacion = cont_contenido.id_instalacion
 AND cont_publicacion.id_contenido = cont_contenido.id_contenido
 AND cont_publicacion.fecha_publicacion = (SELECT cp1.fecha_publicacion
        FROM cont_publicacion cp1
     WHERE cp1.id_instalacion = cont_publicacion.id_instalacion
     AND cp1.id_contenido = cont_publicacion.id_contenido
     AND cp1.generar_vainilla = cont_publicacion.generar_vainilla
     ORDER BY fecha_publicacion LIMIT 1)
ORDER BY  cont_publicacion.fecha_publicacion desc
 LIMIT 10
 OFFSET 0
 ;

                                                                          QUERY PLAN
                                       

---------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=9.75..9.76 rows=1 width=479) (actual time=465085.25..465085.27 rows=8 loops=1)
   ->  Sort  (cost=9.75..9.76 rows=1 width=479) (actual time=465085.23..465085.24 rows=8 loops=1)
         Sort Key: cont_publicacion.fecha_publicacion
         ->  Merge Join  (cost=9.73..9.74 rows=1 width=479) (actual time=210743.83..465083.31 rows=8 loops=1)
               Merge Cond: (("outer".id_instalacion = "inner".id_instalacion) AND ("outer".id_contenido =
"inner".id_contenido))
               ->  Nested Loop  (cost=0.00..284756.79 rows=1 width=367) (actual time=8319.87..464981.68 rows=40
loops=1)
                     Join Filter: (("inner".id_contenido = "outer".id_contenido) AND ("inner".id_instalacion =
"outer".id_instalacion))
                     ->  Index Scan using jue_conf_pk on juegos_config  (cost=0.00..12.19 rows=40 width=332) (actual
time=52.93..142.31rows=40 loops=1) 
                     ->  Seq Scan on cont_publicacion  (cost=0.00..7118.60 rows=1 width=35) (actual
time=51.79..11617.12rows=97 loops=40) 
                           Filter: ((upper((generar_vainilla)::text) = 'S'::text) AND (fecha_publicacion = (subplan)))
                           SubPlan
                             ->  Limit  (cost=15.85..15.85 rows=1 width=8) (actual time=25.86..25.86 rows=1
loops=17880)
                                   ->  Sort  (cost=15.85..15.86 rows=1 width=8) (actual time=25.82..25.82 rows=2
loops=17880)
                                         Sort Key: fecha_publicacion
                                         ->  Seq Scan on cont_publicacion cp1  (cost=0.00..15.84 rows=1 width=8)
(actualtime=10.68..25.32 rows=7 loops=17880) 
                                               Filter: ((id_instalacion = $0) AND (id_contenido = $1) AND
(generar_vainilla= $2)) 
               ->  Sort  (cost=9.73..9.74 rows=3 width=112) (actual time=94.91..94.93 rows=8 loops=1)
                     Sort Key: cont_contenido.id_instalacion, cont_contenido.id_contenido
                     ->  Seq Scan on cont_contenido  (cost=0.00..9.70 rows=3 width=112) (actual time=21.70..92.96
rows=8loops=1) 
                           Filter: ((id_instalacion = 2::numeric) AND (id_sbc = 619::numeric) AND (id_tipo =
2::numeric))
 Total runtime: 465088.66 msec
(21 rows)



-----Mensaje original-----
De: Christopher Browne [mailto:cbbrowne@libertyrms.info]
Enviado el: viernes, 01 de agosto de 2003 18:27
Para: Fernando Papa
CC: pgsql-performance@postgresql.org
Asunto: Re: [PERFORM] I can't wait too much: Total runtime 432478.44 msec



I'd point at the following as being a sterling candidate for being a cause of this being slow...

 AND cont_publicacion.fecha_publicacion = (SELECT max(cp1.fecha_publicacion)
                  FROM cont_publicacion cp1 
                  WHERE cp1.id_instalacion = cont_publicacion.id_instalacion
                    AND cp1.id_contenido = cont_publicacion.id_contenido 
                    AND cp1.generar_vainilla = cont_publicacion.generar_vainilla)    

May I suggest changing it to:

 AND cont_publicacion.fecha_publicacion = (SELECT cp1.fecha_publicacion
                  FROM cont_publicacion cp1 
                  WHERE cp1.id_instalacion = cont_publicacion.id_instalacion
                    AND cp1.id_contenido = cont_publicacion.id_contenido 
                    AND cp1.generar_vainilla = cont_publicacion.generar_vainilla
                  ORDER BY fecha_publicacion LIMIT 1)

That would get rid of the aggregate that's sitting deep in the query.
--
select 'cbbrowne' || '@' || 'libertyrms.info'; <http://dev6.int.libertyrms.com/> Christopher Browne
(416) 646 3304 x124 (land)

pgsql-performance by date:

Previous
From: Manfred Koizar
Date:
Subject: Re: I can't wait too much: Total runtime 432478.44 msec
Next
From: "Fernando Papa"
Date:
Subject: Re: I can't wait too much: Total runtime 432478.44 msec