Re: Compressed TOAST Slicing

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: "Paul Ramsey" <pramsey(at)cleverelephant(dot)ca>
Cc: "Simon Riggs" <simon(at)2ndquadrant(dot)com>,rafia(dot)sabih(at)enterprisedb(dot)com,"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>,"Stephen Frost" <sfrost(at)snowman(dot)net>,"PostgreSQL Hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Compressed TOAST Slicing
Date: 2019-02-20 18:50:07
Message-ID: 92f9b8fd-5a4d-41f1-a4a6-818e6261d69a@manitou-mail.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Paul Ramsey wrote:

> Oddly enough, I couldn't find many/any things that were sensitive to
> left-end decompression. The only exception is "LIKE this%" which
> clearly would be helped, but unfortunately wouldn't be a quick
> drop-in, but a rather major reorganization of the regex handling.

What about starts_with(string, prefix)?

text_starts_with(arg1,arg2) in varlena.c does a full decompression
of arg1 when it could limit itself to the length of the smaller arg2:

Datum
text_starts_with(PG_FUNCTION_ARGS)
....
len1 = toast_raw_datum_size(arg1);
len2 = toast_raw_datum_size(arg2);
if (len2 > len1)
result = false;
else
{
text *targ1 = DatumGetTextPP(arg1);
text *targ2 = DatumGetTextPP(arg2);

result = (memcmp(VARDATA_ANY(targ1), VARDATA_ANY(targ2),
VARSIZE_ANY_EXHDR(targ2)) == 0);
...

Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2019-02-20 18:50:25 Re: Compressed TOAST Slicing
Previous Message Paul Ramsey 2019-02-20 18:45:37 Re: Compressed TOAST Slicing