Search Postgresql Archives

Re: Delete/update with limit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux