Re: Why Postgres doesn't use TID scan?

From: Vladimir Ryabtsev <greatvovan(at)gmail(dot)com>
To: andrew(at)tao11(dot)riddles(dot)org(dot)uk
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: Why Postgres doesn't use TID scan?
Date: 2018-12-19 20:22:03
Message-ID: CAMqTPq=Pu=gS6bg2BqvZU5D=Vj4Ef1qC8wvNDEbmoMUQ7T_m6A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> 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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Andrew Gierth 2018-12-19 22:23:15 Re: Why Postgres doesn't use TID scan?
Previous Message Andrew Gierth 2018-12-19 11:41:27 Re: Why Postgres doesn't use TID scan?