pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chad Wagner <chad.wagner@gmail.com>
To: Sidar López Cruz <sidarlopez@hotmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Very slow queries
Date: Tue, 30 Jan 2007 17:37:17 -0500
Message-ID: <81961ff50701301437t60c5370bvdf165215cbeaeb25@mail.gmail.com> (raw)
In-Reply-To: <BAY132-F4C49B88EDFA35EDBBD618CEA60@phx.gbl>
References: <BAY132-F4C49B88EDFA35EDBBD618CEA60@phx.gbl>

On 1/30/07, Sidar López Cruz <sidarlopez@hotmail.com> wrote:
>
> query: Delete From ceroriesgo.salarios Where numero_patrono Not In (Select
> numero_patrono From ceroriesgo.patronos)
>
> Seq Scan on salarios  (cost=51021.78..298803854359.95 rows=14240077
> width=6)
>   Filter: (NOT (subplan))
>   SubPlan
>     ->  Materialize  (cost=51021.78..69422.58 rows=1032980 width=25)
>           ->  Seq Scan on patronos  (cost=0.00..41917.80 rows=1032980
> width=25)
>

How many rows exist in salarios, but not in patronos?  How many rows are
there in salarios?

What does the explain look like for:

delete
 from ceroriesgo.salarios s
where not exists (select 1
                            from ceroriesgo.patronos
                          where numero_patrono = s.numero_patrono);

Also, is this not a case for a foreign key with a cascade delete?

http://www.postgresql.org/docs/8.2/static/ddl-constraints.html


-- 
Chad
http://www.postgresqlforums.com/

view thread (9+ messages)  latest in thread

Message-ID: <81961ff50701301437t60c5370bvdf165215cbeaeb25@mail.gmail.com>
Permalink:  ../81961ff50701301437t60c5370bvdf165215cbeaeb25@mail.gmail.com/
Also on:    postgresql.org/message-id/81961ff50701301437t60c5370bvdf165215cbeaeb25@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: chad.wagner@gmail.com, sidarlopez@hotmail.com
  Subject: Re: Very slow queries
  In-Reply-To: <81961ff50701301437t60c5370bvdf165215cbeaeb25@mail.gmail.com>
  References: <BAY132-F4C49B88EDFA35EDBBD618CEA60@phx.gbl> <81961ff50701301437t60c5370bvdf165215cbeaeb25@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox