making multiple updates use indexes: howto?

From: Pedro Alves <pmalves(at)think(dot)pt>
To: PostGreSQL <pgsql-general(at)postgresql(dot)org>
Subject: making multiple updates use indexes: howto?
Date: 2003-07-07 16:57:51
Message-ID: 20030707165751.GA19656@cosmos.inesc.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi.

I have a doubt:

If I make:

update stockline set status=3 where id IN (select id from lap_mpdetail_view where lap=3976)

postgres makes an Seq Scan on stockline.

when stockline is big, it is better to make an select id from
lap_mpdetail_view where lap=3976) and programaticaly build the query of the
type update stockline set status=3 where id=X or id=Y or...

There must be a better way... EXISTS also make a seq scan

update stockline set status=3 where id = (select id from
lap_mpdetail_view where lap=3976); returns more than one tuple

Thanks

--
Pedro Miguel G. Alves pmalves(at)think(dot)pt
THINK - Tecnologias de Informação www.think.pt
Tel: +351 21 413 46 00 Av. José Gomes Ferreira
Fax: +351 21 413 46 09 nº 13 1495-139 ALGÉS

Responses

Browse pgsql-general by date

  From Date Subject
Next Message scott.marlowe 2003-07-07 17:35:24 Re: PostgreSQL vs. MySQL
Previous Message Richard Huxton 2003-07-07 15:49:11 Re: Datatypes and performance