Re: Delete/update with limit - Mailing list pgsql-general

From Csaba Nagy
Subject Re: Delete/update with limit
Date
Msg-id 1185294357.8615.37.camel@coppola.muc.ecircle.de
Whole thread Raw
In response to Re: Delete/update with limit  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Tue, 2007-07-24 at 18:19, Tom Lane wrote:
> [ thinks for a bit ... ] Actually, you can do it as of 8.2 or so,
> by abusing the ScalarArrayOp stuff: turn the subquery into an array.
> An example in the regression database:
>
> regression=# explain update tenk1 set ten=ten+1
> regression-#   where ctid = any (array(select ctid from tenk1 limit 10));
>                                QUERY PLAN
> -------------------------------------------------------------------------
>  Tid Scan on tenk1  (cost=0.46..40.71 rows=10 width=250)
>    TID Cond: (ctid = ANY ($0))
>    InitPlan
>      ->  Limit  (cost=0.00..0.46 rows=10 width=6)
>            ->  Seq Scan on tenk1  (cost=0.00..458.00 rows=10000 width=6)
> (5 rows)
>
> It even seems to get the cost estimate right...

Cool, I will use this then (we do have the relevant DB on 8.2). It would
still be nice to have it work directly...

Thanks,
Csaba.



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: varchar does not work too well with IS NOT NULL partial indexes.
Next
From: Viatcheslav Kalinin
Date:
Subject: Pattern matching with index