Re: Why Postgres doesn't use TID scan?

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

 



> The workaround is to do it like this instead:

Strange, I tried to do like this, but the first thing came into my mind was array_agg() not array():

delete from log
where ctid = any(
    select array_agg(ctid) from (
        select ctid from log
        where timestamp < now() at time zone 'pst' - interval '2 month'
        limit 10
    ) v);

This query complained like this:

ERROR: operator does not exist: tid = tid[]
LINE 2: where ctid = any(
                   ^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

Which is strange because both array(select ...) and select array_agg() ... return the same datatype ctid[].

> But of course that's still an ugly hack.

Come on... Due to declarative nature of SQL developers sometimes need to write much dirtier and uglier hacks.
This one is just a fluffy hacky.

--
Vlad

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux