Re: Re: Re: [Pgsql-ayuda] update exists

From: "Xavi Puig" <personal(at)xavihost(dot)com>
To: Pgsql-ayuda(at)tlali(dot)iztacala(dot)unam(dot)mx <Pgsql-ayuda(at)tlali(dot)iztacala(dot)unam(dot)mx>
Subject: Re: Re: Re: [Pgsql-ayuda] update exists
Date: 2002-10-24 16:15:05
Message-ID: 20031023151513.2C5F08811B@smtp-01.servidoresdns.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Perdn, se me habia olvidado la query:

UPDATE tab1 SET col20=false WHERE exists (select * from (select * from tab1 where col20=true) as alias0,tab2,tab3 where (tab2.col2=tab3.col1 and tab3.col2=alias0.col1) and ( tab2.col2=20500))

Result (cost=0.00..5705.67 rows=267967 width=60)
One-Time Filter: $0
InitPlan
-> Nested Loop (cost=0.00..9739.17 rows=214 width=91)
-> Nested Loop (cost=0.00..8464.72 rows=214 width=36)
-> Index Scan using col2_btrre_col2 on tab2 (cost=0.00..7.10 rows=1 width=28)
Index Cond: (col2 = 20500::character varying)
-> Index Scan using col2_pkey on tab3 (cost=0.00..6560.53 rows=3035 width=8)
Index Cond: ("outer".id_word = tab3.col1)
-> Index Scan using col1_pkey on tab1 (cost=0.00..5.95 rows=1 width=55)
Index Cond: ("outer".col2 = tab1.col1)
Filter: (col20 = true)
-> Seq Scan on tab1 (cost=0.00..5705.67 rows=267967 width=60)

Los campos tienen indices, la subquery funciona bien (rapido) pero al actualizar todo el resultado....
En el ejemplo de ahora el coste es mucho menor pero se cuelga igual
Gracias otra vez.

>On Thu, Oct 24, 2002 at 10:25:21AM +0100, Xavi Puig wrote:
>> Os adjunto explain con query ejemplo:
>
>Falt adjuntar la consulta. Pero lo que sospecho es que tab1 no tiene
>un ndice apropiado en la columna que est devolviendo la subconsulta...
>
>Dej mi bola de cristal en la casa, de manera que tendrs que indicar
>las definiciones de las tablas y la consulta que ests ejecutando.
>
>> QUERY PLAN
>> Seq Scan on tab1 (cost=0.00..22726480.50 rows=133984 width=57)
>> Filter: (subplan)
>> SubPlan
>> -> Hash Join (cost=6.45..84.68 rows=1 width=16)
>> Hash Cond: ("outer".tab2 = "inner".col2)
>> -> Nested Loop (cost=0.00..78.09 rows=29 width=12)
>> -> Index Scan using tab1_col1 on tab1 (cost=0.00..2.01 rows=1 width=4)
>> Index Cond: (col1 = true)
>> -> Index Scan using btree_tab3_col2 on tab3 (cost=0.00..75.65 rows=34 width=8)
>> Index Cond: (tab3.col2 = "outer".col2)
>> -> Hash (cost=6.45..6.45 rows=1 width=4)
>> -> Index Scan using btree_tab2_col2 on tab2 (cost=0.00..6.45 rows=1 width=4)
>> Index Cond: (col2 = 'keyword1'::character varying)
>
>--
>Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
>"El que vive para el futuro es un iluso, y el que vive para el pasado,
>un imbcil" (Luis Adler, "Los tripulantes de la noche")

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Docume 2002-10-24 17:59:44 [Pgsql-ayuda] instalacion en redhat 7.3
Previous Message Xavi Puig 2002-10-24 09:25:21 Re: Re: [Pgsql-ayuda] update exists