Skip site navigation (1) Skip section navigation (2)

Re: Very slow queries

From: "Chad Wagner" <chad(dot)wagner(at)gmail(dot)com>
To: Sidar López Cruz <sidarlopez(at)hotmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Very slow queries
Date: 2007-01-30 22:37:17
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
On 1/30/07, Sidar López Cruz <sidarlopez(at)hotmail(dot)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:

 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?


In response to


pgsql-performance by date

Next:From: Josh BerkusDate: 2007-01-30 23:00:42
Subject: Re: Querying distinct values from a large table
Previous:From: Sidar López CruzDate: 2007-01-30 21:19:41
Subject: Re: Very slow queries

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group