Re: problemas en postgresql -- ayuda !!!!!!

From: tania gutierrez <tanitamile(at)yahoo(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: problemas en postgresql -- ayuda !!!!!!
Date: 2005-07-29 01:18:22
Message-ID: 20050729011822.4955.qmail@web52902.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> escribió:
On Thu, Jul 28, 2005 at 07:10:10PM -0500, tania gutierrez wrote:

> EXPLAIN analyze SELECT a.* from prueba.apli a, prueba.usuariop b , prueba.usuariopa c where b.USPO_ID=c.USPO_ID and c.APLI_ID=a.APLI_ID and b.USUA_ID=3939 and b.PORL_ID=1 and c.USPA_ESTADO='V' order by c.USPA_ORDEN;
> -------------------------------------------------------------------------------------------------------------------------------------------------------
> Sort (cost=1360.78..1360.78 rows=1 width=495) (actual time=750.070..750.072 rows=1 loops=1)
> Sort Key: c.uspa_orden
> -> Nested Loop (cost=1338.66..1360.77 rows=1 width=495) (actual time=121.309..749.863 rows=1 loops=1)
> Join Filter: ("outer".apli_id = "inner".apli_id)
> -> Nested Loop (cost=1338.66..1358.96 rows=1 width=33) (actual time=120.890..749.427 rows=1 loops=1)
> Join Filter: ("outer".uspo_id = "inner".uspo_id)
> -> Index Scan using uspo_uk on usuariop b (cost=0.00..8.37 rows=2 width=23) (actual time=0.106..0.119 rows=1 loops=1)
> Index Cond: ((usua_id = 3939::numeric) AND (porl_id = 1::numeric))
> -> Materialize (cost=1338.66..1341.31 rows=265 width=56) (actual time=0.051..621.947 rows=52851 loops=1)
> -> Seq Scan on usuariopa c (cost=0.00..1338.66 rows=265 width=56) (actual time=0.040..423.953 rows=52851 loops=1)
> Filter: (uspa_estado = 'V'::text)
> -> Seq Scan on aplicacion a (cost=0.00..1.36 rows=36 width=485) (actual time=0.024..0.290 rows=36 loops=1)
> Total runtime: 752.680 ms
> (13 filas)

Hummm!!! Haz hecho ANALYZE sobre la tabla usuariopa? La estimacion de
filas difiere en dos ordenes de magnitud de la realidad:

-> Seq Scan on usuariopa c (cost=0.00..1338.66 rows=265 width=56) (actual time=0.040..423.953 rows=52851 loops=1)

Haz un ANALYZE a esa tabla y repite la consulta, a ver si mejora esta
estimacion.

> Puede ser problemas de transaccionalidad en el postmaster y el driver de posgtresql?

No, el problema es que la consulta no se esta ejecutando optimamente.

los expain a las tabals me arrojan el siguiente resultado:

EXPLAIN analyze SELECT * from prueba.usuariopa ;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------
Seq Scan on usuariopa (cost=0.00..1206.53 rows=52853 width=152) (actual time=0.010..100.626 rows=52853 loops=1)
Total runtime: 170.607 ms
(2 filas)

EXPLAIN analyze SELECT * from prueba.usuariop ;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------
Seq Scan on usuariop (cost=0.00..1448.85 rows=63485 width=152) (actual time=0.026..131.408 rows=63485 loops=1)
Total runtime: 311.911 ms
(2 filas)

EXPLAIN analyze SELECT * from prueba.aplicacion ;
QUERY PLAN
--------------------------------------------------------------------------------------------------------
Seq Scan on apli (cost=0.00..1.36 rows=36 width=485) (actual time=0.027..0.287 rows=36 loops=1)
Total runtime: 0.400 ms

y si modifico la consulta de esta forma:

SELECT a.* from
prueba.usuariop b inner join prueba.usuariopapli c on (b.USPO_ID=c.USPO_ID and b.USUA_ID=3939 and b.PORL_ID=1)
inner join prueba.apli a on (c.APLI_ID=a.APLI_ID and c.USPA_ESTADO='V' )
order by c.USPA_ORDEN;

al aplicarle el expain analize me da esta rta:

QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------
Sort (cost=1360.78..1360.78 rows=1 width=495) (actual time=635.649..635.651 rows=1 loops=1)
Sort Key: c.uspa_orden
-> Nested Loop (cost=1338.66..1360.77 rows=1 width=495) (actual time=119.527..635.623 rows=1 loops=1)
Join Filter: ("outer".apli_id = "inner".apli_id)
-> Nested Loop (cost=1338.66..1358.96 rows=1 width=33) (actual time=119.127..635.205 rows=1 loops=1)
Join Filter: ("outer".uspo_id = "inner".uspo_id)
-> Index Scan using uspo_uk on usuariop b (cost=0.00..8.37 rows=2 width=23) (actual time=0.073..0.088 rows=1 loops=1)
Index Cond: ((usua_id = 3939::numeric) AND (porl_id = 1::numeric))
-> Materialize (cost=1338.66..1341.31 rows=265 width=56) (actual time=0.039..507.613 rows=52851 loops=1)
-> Seq Scan on usuariopapli c (cost=0.00..1338.66 rows=265 width=56) (actual time=0.032..313.053 rows=52851 loops=1)
Filter: (uspa_estado = 'V'::text)
-> Seq Scan on apli a (cost=0.00..1.36 rows=36 width=485) (actual time=0.018..0.265 rows=36 loops=1)
Total runtime: 638.244 ms
(13 filas)

otra pregunta no sera problemas con el syslog yo no tengo activo estas variables de sincronizacion

checkpoint_segments = 3
checkpoint_timeout = 300
fsync = true

que me recomiendas?

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
Regístrate ya - http://correo.espanol.yahoo.com/

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Alvaro Herrera 2005-07-29 01:21:19 Re: problemas en postgresql -- ayuda !!!!!!
Previous Message Alvaro Herrera 2005-07-29 01:01:02 Re: BAckup no toma columnas nuevas.