Обсуждение: pgsql: Provide hashing support for arrays.

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

pgsql: Provide hashing support for arrays.

От
Tom Lane
Дата:
Provide hashing support for arrays.

The core of this patch is hash_array() and associated typcache
infrastructure, which works just about exactly like the existing support
for array comparison.

In addition I did some work to ensure that the planner won't think that an
array type is hashable unless its element type is hashable, and similarly
for sorting.  This includes adding a datatype parameter to op_hashjoinable
and op_mergejoinable, and adding an explicit "hashable" flag to
SortGroupClause.  The lack of a cross-check on the element type was a
pre-existing bug in mergejoin support --- but it didn't matter so much
before, because if you couldn't sort the element type there wasn't any good
alternative to failing anyhow.  Now that we have the alternative of hashing
the array type, there are cases where we can avoid a failure by being picky
at the planner stage, so it's time to be picky.

The issue of exactly how to combine the per-element hash values to produce
an array hash is still open for discussion, but the rest of this is pretty
solid, so I'll commit it as-is.

Branch
------
master

Details
-------
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=186cbbda8f8dc5e42f68fc7892f206a76d56a20f

Modified Files
--------------
src/backend/commands/analyze.c          |    3 +-
src/backend/nodes/copyfuncs.c           |    1 +
src/backend/nodes/equalfuncs.c          |    1 +
src/backend/nodes/outfuncs.c            |    1 +
src/backend/nodes/readfuncs.c           |    1 +
src/backend/optimizer/path/equivclass.c |    4 +-
src/backend/optimizer/plan/createplan.c |    1 +
src/backend/optimizer/plan/initsplan.c  |    9 ++-
src/backend/optimizer/plan/planagg.c    |    1 +
src/backend/optimizer/plan/subselect.c  |   39 ++++++++---
src/backend/optimizer/util/pathnode.c   |    7 ++-
src/backend/optimizer/util/tlist.c      |    8 +--
src/backend/parser/analyze.c            |    5 +-
src/backend/parser/parse_clause.c       |   23 +++++--
src/backend/parser/parse_oper.c         |   51 ++++++++-------
src/backend/utils/adt/arrayfuncs.c      |  111 +++++++++++++++++++++++++++++++
src/backend/utils/cache/lsyscache.c     |   75 +++++++++++++++++----
src/backend/utils/cache/typcache.c      |   71 +++++++++++++++++---
src/include/catalog/catversion.h        |    2 +-
src/include/catalog/pg_amop.h           |    2 +
src/include/catalog/pg_amproc.h         |    1 +
src/include/catalog/pg_opclass.h        |    1 +
src/include/catalog/pg_operator.h       |    2 +-
src/include/catalog/pg_opfamily.h       |    1 +
src/include/catalog/pg_proc.h           |    3 +
src/include/nodes/parsenodes.h          |    8 ++
src/include/parser/parse_oper.h         |    3 +-
src/include/utils/array.h               |    1 +
src/include/utils/lsyscache.h           |    4 +-
src/include/utils/typcache.h            |   23 ++++---
30 files changed, 375 insertions(+), 88 deletions(-)


Re: pgsql: Provide hashing support for arrays.

От
Bruce Momjian
Дата:
I assume this completes this TODO item, so I have marked it as done:

    Incomplete itemAllow hashing to be used on arrays, if the element type
    is hashable

    http://archives.postgresql.org/message-id/11087.1244905821@sss.pgh.pa.us

---------------------------------------------------------------------------

Tom Lane wrote:
> Provide hashing support for arrays.
>
> The core of this patch is hash_array() and associated typcache
> infrastructure, which works just about exactly like the existing support
> for array comparison.
>
> In addition I did some work to ensure that the planner won't think that an
> array type is hashable unless its element type is hashable, and similarly
> for sorting.  This includes adding a datatype parameter to op_hashjoinable
> and op_mergejoinable, and adding an explicit "hashable" flag to
> SortGroupClause.  The lack of a cross-check on the element type was a
> pre-existing bug in mergejoin support --- but it didn't matter so much
> before, because if you couldn't sort the element type there wasn't any good
> alternative to failing anyhow.  Now that we have the alternative of hashing
> the array type, there are cases where we can avoid a failure by being picky
> at the planner stage, so it's time to be picky.
>
> The issue of exactly how to combine the per-element hash values to produce
> an array hash is still open for discussion, but the rest of this is pretty
> solid, so I'll commit it as-is.
>
> Branch
> ------
> master
>
> Details
> -------
> http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=186cbbda8f8dc5e42f68fc7892f206a76d56a20f
>
> Modified Files
> --------------
> src/backend/commands/analyze.c          |    3 +-
> src/backend/nodes/copyfuncs.c           |    1 +
> src/backend/nodes/equalfuncs.c          |    1 +
> src/backend/nodes/outfuncs.c            |    1 +
> src/backend/nodes/readfuncs.c           |    1 +
> src/backend/optimizer/path/equivclass.c |    4 +-
> src/backend/optimizer/plan/createplan.c |    1 +
> src/backend/optimizer/plan/initsplan.c  |    9 ++-
> src/backend/optimizer/plan/planagg.c    |    1 +
> src/backend/optimizer/plan/subselect.c  |   39 ++++++++---
> src/backend/optimizer/util/pathnode.c   |    7 ++-
> src/backend/optimizer/util/tlist.c      |    8 +--
> src/backend/parser/analyze.c            |    5 +-
> src/backend/parser/parse_clause.c       |   23 +++++--
> src/backend/parser/parse_oper.c         |   51 ++++++++-------
> src/backend/utils/adt/arrayfuncs.c      |  111 +++++++++++++++++++++++++++++++
> src/backend/utils/cache/lsyscache.c     |   75 +++++++++++++++++----
> src/backend/utils/cache/typcache.c      |   71 +++++++++++++++++---
> src/include/catalog/catversion.h        |    2 +-
> src/include/catalog/pg_amop.h           |    2 +
> src/include/catalog/pg_amproc.h         |    1 +
> src/include/catalog/pg_opclass.h        |    1 +
> src/include/catalog/pg_operator.h       |    2 +-
> src/include/catalog/pg_opfamily.h       |    1 +
> src/include/catalog/pg_proc.h           |    3 +
> src/include/nodes/parsenodes.h          |    8 ++
> src/include/parser/parse_oper.h         |    3 +-
> src/include/utils/array.h               |    1 +
> src/include/utils/lsyscache.h           |    4 +-
> src/include/utils/typcache.h            |   23 ++++---
> 30 files changed, 375 insertions(+), 88 deletions(-)
>
>
> --
> Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-committers

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +