From: Marc Morin <marc@sandvine.com>
To: Scott Marlowe <smarlowe@g2switchworks.com>
To: Andrus <eetasoft@online.ee>
Cc: pgsql-performance@postgresql.org
Subject: Re: Query runs too long for indexed tables
Date: Tue, 4 Apr 2006 16:00:13 -0400
Message-ID: <2BCEB9A37A4D354AA276774EE13FB8C2BCC555@mailserver.sandvine.com> (raw)
Wondering if
Update firma1.rid set toode=null where toode is not null and not
exists(select 1 from firma1.toode where toode=rid.toode);
Would be faster... Problem appears to be the seqscan of seqscan... No?
> -----Original Message-----
> From: pgsql-performance-owner@postgresql.org
> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of
> Scott Marlowe
> Sent: Tuesday, April 04, 2006 3:49 PM
> To: Andrus
> Cc: pgsql-performance@postgresql.org
> Subject: Re: [PERFORM] Query runs too long for indexed tables
>
> On Tue, 2006-04-04 at 14:37, Andrus wrote:
> > I have relatively small tables (toode and rid) in fast server.
> > Both tables are indexed on toode field.
> >
> > Following query takes long time to run.
> > toode field type is char(20). It is difficult to change
> this field type.
> >
> > Any idea how to speed up this query ?
> >
> > UPDATE firma1.rid SET toode=NULL
> > WHERE toode IS NOT NULL AND
> > toode NOT IN (SELECT TOODE FROM firma1.TOODE);
> >
> > Query returned successfully: 0 rows affected, 594813 ms
> execution time.
> >
> > explain window shows:
> >
> > Seq Scan on rid (cost=2581.07..20862553.77 rows=51848 width=1207)
> > Filter: ((toode IS NOT NULL) AND (NOT (subplan)))
> > SubPlan
> > -> Materialize (cost=2581.07..2944.41 rows=14734 width=84)
> > -> Seq Scan on toode (cost=0.00..2350.34 rows=14734
> > width=84)
>
> Let me guess, you've updated it a lot and aren't familiar with Vacuum?
>
> run a vacuum full on your database. schedule a vacuum (plain
> one) to run every so often (hours or days are a good interval
> for most folks)
>
> If that's NOT your problem, then please, let us know.
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: marc@sandvine.com, smarlowe@g2switchworks.com, eetasoft@online.ee
Subject: Re: Query runs too long for indexed tables
In-Reply-To: <2BCEB9A37A4D354AA276774EE13FB8C2BCC555@mailserver.sandvine.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