Re: making multiple updates use indexes: howto?

From: "Jim C(dot) Nasby" <jim(at)nasby(dot)net>
To: Mike Mascari <mascarm(at)mascari(dot)com>
Cc: Pedro Alves <pmalves(at)think(dot)pt>, PostGreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: making multiple updates use indexes: howto?
Date: 2003-07-09 14:32:58
Message-ID: 20030709143258.GJ69704@nasby.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jul 07, 2003 at 05:58:00PM -0400, Mike Mascari wrote:
> 2. I've found the following syntax to perform better, although I'm not
> sure of its portability:
>
> UPDATE stockline SET status = 3
> WHERE stockline.id = lap_mpdetail_view.id AND
> lap_mpdetail_view.lap = 3976;

Very un-portable. PGSQL is the only database I know of that will
construct a FROM clause for you on it's own. You should at least add

FROM lap_mpdetail_view

to the update. Even that isn't highly portable, though at least some
databases support that syntax. (Sybase and MS SQL come to mind).

--
Jim C. Nasby, Database Consultant jim(at)nasby(dot)net
Member: Triangle Fraternity, Sports Car Club of America
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michal Zaborowski 2003-07-09 15:21:47 Re: Native dataprovider on Windows
Previous Message Bjørn T Johansen 2003-07-09 14:01:38 Re: Sorting on fieldtype Time?