Re: Yet another fast GiST build

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Peter Geoghegan <pg(at)bowt(dot)ie>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, Darafei Komяpa Praliaskouski <me(at)komzpa(dot)net>, Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Ibrar Ahmed <ibrar(dot)ahmad(at)gmail(dot)com>
Subject: Re: Yet another fast GiST build
Date: 2021-05-07 13:05:41
Message-ID: 7DE8A009-5F8E-4D87-8E53-AC91E473DCD4@yandex-team.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for the investigation, Heikki.

> 8 апр. 2021 г., в 01:18, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> написThe correct pattern would be something like this (without the debugging NOTICE, of course):
>
>> static int
>> gbt_text_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
>> {
>> GBT_VARKEY_R ra = gbt_var_key_readable((GBT_VARKEY *) PG_DETOAST_DATUM(a));
>> GBT_VARKEY_R rb = gbt_var_key_readable((GBT_VARKEY *) PG_DETOAST_DATUM(b));
>> int x = DatumGetInt32(DirectFunctionCall2Coll(bttextcmp,
>> ssup->ssup_collation,
>> PointerGetDatum(a),
>> PointerGetDatum(b)));
>> elog(NOTICE, "cmp: %s vs %s: %d",
>> TextDatumGetCString(ra.lower),
>> TextDatumGetCString(rb.lower),
>> x);
>> return x;
>> }
>

In this pattern I flipped PointerGetDatum(a) to PointerGetDatum(ra.lower), because it seems to me correct. I've followed rule of thumb: every sort function must extract and user "lower" somehow. Though I suspect numeric a bit. Is it regular varlena?
PFA patchset with v6 intact + two fixes of discovered issues.

Thanks!

Best regards, Andrey Borodin.

Attachment Content-Type Size
v7-0001-Add-sortsupport-for-gist_btree-opclasses-for-fast.patch application/octet-stream 82.9 KB
v7-0002-Remove-DEBUG1-verification-of-the-fact-that-index.patch application/octet-stream 35.7 KB
v7-0003-Fix-varlen-keys-sorting.patch application/octet-stream 3.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2021-05-07 13:14:27 Re: Identify missing publications from publisher while create/alter subscription.
Previous Message Jeevan Ladhe 2021-05-07 12:53:06 Re: Query regarding RANGE Partitioning