Обсуждение: Patch: Pass IndexInfo correctly to aminsert for indexes on TOAST

Поиск
Список
Период
Сортировка

Patch: Pass IndexInfo correctly to aminsert for indexes on TOAST

От
"Ahuja, Nitin"
Дата:

Hi,

I wanted to submit the below patch.

Patch Description
Currently, while saving the TOAST entry the call to index access method insert (aminsert) passed IndexInfo attribute as NULL. IndexInfo parameter was introduced in Postgres 10 for the aminsert method to allow caching data across aminsert calls within a single SQL statement. The IndexInfo is passed correctly for regular tuple insertion but not for TOAST entries. This currently prohibits aminsert method to be able to use IndexInfo for TOAST entries.

This patch correctly passes the built IndexInfo to aminsert for TOAST entries.

 

Context Diff for Patch Submission

 

*** postgres_patch/postgres/src/backend/access/heap/tuptoaster.c      2018-02-18 11:54:02.000000000 -0800

--- postgres/postgres/src/backend/access/heap/tuptoaster.c      2018-02-18 12:14:07.000000000 -0800

***************

*** 43,49 ****

  #include "utils/snapmgr.h"

  #include "utils/typcache.h"

  #include "utils/tqual.h"

- #include "catalog/index.h"

 

 

  #undef TOAST_DEBUG

--- 43,48 ----

***************

*** 1671,1677 ****

                                 * Create the index entry.  We cheat a little here by not using

                                 * FormIndexDatum: this relies on the knowledge that the index columns

                                 * are the same as the initial columns of the table for all the

!                               * indexes.

                                 *

                                 * Note also that there had better not be any user-created index on

                                 * the TOAST table, since we don't bother to update anything else.

--- 1670,1678 ----

                                 * Create the index entry.  We cheat a little here by not using

                                 * FormIndexDatum: this relies on the knowledge that the index columns

                                 * are the same as the initial columns of the table for all the

!                               * indexes.  We also cheat by not providing an IndexInfo: this is okay

!                               * for now because btree doesn't need one, but we might have to be

!                               * more honest someday.

                                 *

                                 * Note also that there had better not be any user-created index on

                                 * the TOAST table, since we don't bother to update anything else.

***************

*** 1685,1691 ****

                                                                                                                 toastrel,

                                                                                                                 toastidxs[i]->rd_index->indisunique ?

                                                                                                                 UNIQUE_CHECK_YES : UNIQUE_CHECK_NO,

!                                                                                                               BuildIndexInfo(toastidxs[i]));

                                }

 

                                /*

--- 1686,1692 ----

                                                                                                                 toastrel,

                                                                                                                 toastidxs[i]->rd_index->indisunique ?

                                                                                                                 UNIQUE_CHECK_YES : UNIQUE_CHECK_NO,

!                                                                                                               NULL);

                                }

 

                                /*




Thanks,
Nitin Ahuja

Re: Patch: Pass IndexInfo correctly to aminsert for indexes on TOAST

От
Robert Haas
Дата:
On Thu, Feb 22, 2018 at 9:13 PM, Ahuja, Nitin <nitahuja@amazon.com> wrote:
> Patch Description
> Currently, while saving the TOAST entry the call to index access method
> insert (aminsert) passed IndexInfo attribute as NULL. IndexInfo parameter
> was introduced in Postgres 10 for the aminsert method to allow caching data
> across aminsert calls within a single SQL statement. The IndexInfo is passed
> correctly for regular tuple insertion but not for TOAST entries. This
> currently prohibits aminsert method to be able to use IndexInfo for TOAST
> entries.
>
> This patch correctly passes the built IndexInfo to aminsert for TOAST
> entries.

If you don't offer any justification for the patch it's unlikely to be
accepted.  BuildIndexInfo() isn't free, so unless it hurts something
to skip calling it, we should keep skipping it.

Also, your patch is (a) in the body of the email instead of attached,
(b) in HTML format, and (c) reversed -- if it were properly formatted,
the original hunks would be first and the revised ones second.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company