You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by ma...@apache.org on 2025/02/20 01:13:53 UTC

(cloudberry) 01/08: Merge pg_hint_plan source tree into GPDB

This is an automated email from the ASF dual-hosted git repository.

maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 2900bc638c1d14b77e4a8cddf0502b4d684fe066
Author: David Kimura <dk...@vmware.com>
AuthorDate: Thu Jan 18 14:52:21 2024 -0800

    Merge pg_hint_plan source tree into GPDB
    
    The purpose for merging pg_hint_plan into GPDB branch is to streamline
    ORCA plan hints development.
    
    ORCA usage of pg_hint_plan is more coupled to the extension than
    PLANNER. In other words, updating pg_hint_plan code is not enough for
    ORCA to generate a plan that abides a new hint rule. That's because ORCA
    only uses pg_hint_plan to parse a query tree into hints that are fed
    into ORCA optimizer.  Whereas PLANNER uses pg_hint_plan to directly
    generate a plan from the query tree.
    
    This merge commit includes all pg_hint_plan commits until dfb7d34c4
    (PG12)
    
    Add 'gpcontrib/pg_hint_plan/' from commit '7e57354260d5b2bde644e2c6bbd1ad037ff8d561'
    
    git-subtree-dir: gpcontrib/pg_hint_plan
    git-subtree-mainline: 550637c0d0e3cb220958ab14427037e7fc60df58
    git-subtree-split: 7e57354260d5b2bde644e2c6bbd1ad037ff8d561
---
 gpcontrib/pg_hint_plan/.gitattributes              |    2 +
 gpcontrib/pg_hint_plan/.github/workflows/test.yml  |   95 +
 gpcontrib/pg_hint_plan/.gitignore                  |   15 +
 gpcontrib/pg_hint_plan/COPYRIGHT                   |   26 +
 gpcontrib/pg_hint_plan/COPYRIGHT.postgresql        |   24 +
 gpcontrib/pg_hint_plan/META.json                   |   45 +
 gpcontrib/pg_hint_plan/Makefile                    |   64 +
 gpcontrib/pg_hint_plan/SPECS/pg_hint_plan12.spec   |  106 +
 gpcontrib/pg_hint_plan/core.c                      | 1230 +++
 gpcontrib/pg_hint_plan/data/data.csv               |   10 +
 gpcontrib/pg_hint_plan/doc/hint_list-ja.html       |  113 +
 gpcontrib/pg_hint_plan/doc/hint_list.html          |   95 +
 gpcontrib/pg_hint_plan/doc/pg_hint_plan-ja.html    |  700 ++
 gpcontrib/pg_hint_plan/doc/pg_hint_plan.html       |  508 ++
 gpcontrib/pg_hint_plan/doc/style.css               |  110 +
 gpcontrib/pg_hint_plan/expected/.gitignore         |    2 +
 gpcontrib/pg_hint_plan/expected/R_sample.out       |   10 +
 gpcontrib/pg_hint_plan/expected/base_plan.out      |   77 +
 gpcontrib/pg_hint_plan/expected/init.out           |  212 +
 gpcontrib/pg_hint_plan/expected/oldextversions.out |   94 +
 gpcontrib/pg_hint_plan/expected/pg_hint_plan.out   | 9166 ++++++++++++++++++++
 gpcontrib/pg_hint_plan/expected/plpgsql.out        |  406 +
 gpcontrib/pg_hint_plan/expected/ut-A.out           | 4810 ++++++++++
 gpcontrib/pg_hint_plan/expected/ut-G.out           |  878 ++
 gpcontrib/pg_hint_plan/expected/ut-J.out           | 4719 ++++++++++
 gpcontrib/pg_hint_plan/expected/ut-L.out           | 4465 ++++++++++
 gpcontrib/pg_hint_plan/expected/ut-R.out           | 5017 +++++++++++
 gpcontrib/pg_hint_plan/expected/ut-S.out           | 6182 +++++++++++++
 gpcontrib/pg_hint_plan/expected/ut-T.out           |  138 +
 gpcontrib/pg_hint_plan/expected/ut-W.out           | 1318 +++
 gpcontrib/pg_hint_plan/expected/ut-fini.out        |    3 +
 gpcontrib/pg_hint_plan/expected/ut-init.out        |  212 +
 gpcontrib/pg_hint_plan/input/ut-fdw.source         |   51 +
 gpcontrib/pg_hint_plan/make_join_rel.c             |  386 +
 gpcontrib/pg_hint_plan/normalize_query.h           |   55 +
 gpcontrib/pg_hint_plan/output/ut-fdw.source        |  148 +
 .../pg_hint_plan/pg_hint_plan--1.3.0--1.3.1.sql    |   10 +
 gpcontrib/pg_hint_plan/pg_hint_plan--1.3.0.sql     |   22 +
 .../pg_hint_plan/pg_hint_plan--1.3.1--1.3.2.sql    |   10 +
 .../pg_hint_plan/pg_hint_plan--1.3.2--1.3.3.sql    |   10 +
 .../pg_hint_plan/pg_hint_plan--1.3.3--1.3.4.sql    |   10 +
 .../pg_hint_plan/pg_hint_plan--1.3.4--1.3.5.sql    |   10 +
 .../pg_hint_plan/pg_hint_plan--1.3.5--1.3.6.sql    |   10 +
 .../pg_hint_plan/pg_hint_plan--1.3.6--1.3.7.sql    |   10 +
 .../pg_hint_plan/pg_hint_plan--1.3.7--1.3.8.sql    |   10 +
 .../pg_hint_plan/pg_hint_plan--1.3.8--1.3.9.sql    |   10 +
 gpcontrib/pg_hint_plan/pg_hint_plan.c              | 5015 +++++++++++
 gpcontrib/pg_hint_plan/pg_hint_plan.control        |    6 +
 gpcontrib/pg_hint_plan/pg_stat_statements.c        |  922 ++
 gpcontrib/pg_hint_plan/sql/.gitignore              |    1 +
 gpcontrib/pg_hint_plan/sql/base_plan.sql           |   14 +
 gpcontrib/pg_hint_plan/sql/init.sql                |  135 +
 gpcontrib/pg_hint_plan/sql/maskout.sh              |    4 +
 gpcontrib/pg_hint_plan/sql/maskout2.sh             |    3 +
 gpcontrib/pg_hint_plan/sql/oldextversions.sql      |   25 +
 gpcontrib/pg_hint_plan/sql/pg_hint_plan.sql        | 1163 +++
 gpcontrib/pg_hint_plan/sql/plpgsql.sql             |  105 +
 gpcontrib/pg_hint_plan/sql/ut-A.sql                | 1257 +++
 gpcontrib/pg_hint_plan/sql/ut-G.sql                |  129 +
 gpcontrib/pg_hint_plan/sql/ut-J.sql                |  831 ++
 gpcontrib/pg_hint_plan/sql/ut-L.sql                |  726 ++
 gpcontrib/pg_hint_plan/sql/ut-R.sql                | 1402 +++
 gpcontrib/pg_hint_plan/sql/ut-S.sql                | 1201 +++
 gpcontrib/pg_hint_plan/sql/ut-T.sql                |   48 +
 gpcontrib/pg_hint_plan/sql/ut-W.sql                |  225 +
 gpcontrib/pg_hint_plan/sql/ut-fini.sql             |    3 +
 gpcontrib/pg_hint_plan/sql/ut-init.sql             |  169 +
 gpcontrib/pg_hint_plan/update_copied_funcs.pl      |  325 +
 68 files changed, 55313 insertions(+)

diff --git a/gpcontrib/pg_hint_plan/.gitattributes b/gpcontrib/pg_hint_plan/.gitattributes
new file mode 100644
index 0000000000..4e9126d554
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/.gitattributes
@@ -0,0 +1,2 @@
+# Test output files that contain extra whitespace
+*.out					-whitespace
diff --git a/gpcontrib/pg_hint_plan/.github/workflows/test.yml b/gpcontrib/pg_hint_plan/.github/workflows/test.yml
new file mode 100644
index 0000000000..ce9134e92a
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/.github/workflows/test.yml
@@ -0,0 +1,95 @@
+name: regression test
+on:
+  push:
+    branches:
+      - PG16
+      - PG15
+      - PG14
+      - PG13
+      - PG12
+      - PG11
+  pull_request:
+    branches:
+      - PG16
+      - PG15
+      - PG14
+      - PG13
+      - PG12
+      - PG11
+  schedule:
+    # Runs at 00:00 UTC on every Sunday.
+    - cron: "0 0 * * SUN"
+
+jobs:
+  test:
+    strategy:
+      fail-fast: false
+
+    runs-on: ubuntu-latest
+
+    env:
+      PGPORT: 55435
+      PGUSER: runner
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Set PATH and PG_VERSION
+        run: |
+          if [ "${{ github.ref_name }}" == 'PG16' ]; then
+            echo "PG_VERSION=16" >> $GITHUB_ENV
+          elif [ "${{ github.ref_name }}" == 'PG15' ]; then
+            echo "PG_VERSION=15" >> $GITHUB_ENV
+          elif [ "${{ github.ref_name }}" == 'PG14' ]; then
+            echo "PG_VERSION=14" >> $GITHUB_ENV
+          elif [ "${{ github.ref_name }}" == 'PG13' ]; then
+            echo "PG_VERSION=13" >> $GITHUB_ENV
+          elif [ "${{ github.ref_name }}" == 'PG12' ]; then
+            echo "PG_VERSION=12" >> $GITHUB_ENV
+          elif [ "${{ github.ref_name }}" == 'PG11' ]; then
+            echo "PG_VERSION=11" >> $GITHUB_ENV
+          fi
+
+      - name: Build PostgreSQL
+        run: |
+          sudo -nH apt-get -q update
+          sudo -nH apt-get -y install libreadline-dev zlib1g-dev bison flex gcc
+          wget -q -O postgresql.tar.bz2 https://ftp.postgresql.org/pub/snapshot/${PG_VERSION}/postgresql-${PG_VERSION}-snapshot.tar.bz2
+          mkdir -p ~/source
+          tar --extract --file postgresql.tar.bz2 --directory ~/source --strip-components 1
+          cd ~/source
+          ./configure --prefix=$HOME/pgsql --enable-cassert --enable-debug
+
+          make -j 2
+          make -C contrib/pg_stat_statements
+          make -C contrib/file_fdw
+          make -C contrib/btree_gist
+          make -C contrib/btree_gin
+
+          sudo make install
+          sudo make -C contrib/pg_stat_statements install
+          sudo make -C contrib/file_fdw install
+          sudo make -C contrib/btree_gist install
+          sudo make -C contrib/btree_gin install
+
+          echo "$HOME/pgsql/bin" >> $GITHUB_PATH
+
+      - name: Build pg_hint_plan
+        run: |
+          make USE_PGXS=1 clean
+          make USE_PGXS=1 PG_CONFIG=$(which pg_config)
+          sudo make USE_PGXS=1 PG_CONFIG=$(which pg_config) install
+
+      - name: Start PostgreSQL Server
+        run: |
+          initdb -D regression_data --no-locale -E UTF8 -A trust
+          echo "shared_preload_libraries = 'pg_hint_plan,pg_stat_statements,file_fdw'" >> regression_data/postgresql.conf
+          pg_ctl start -D regression_data -o "-p ${PGPORT}"
+
+      - name: Make installcheck
+        run: |
+          make installcheck USE_PGXS=1 || status=$?
+          if test -f regression.diffs; then cat regression.diffs; fi
+          exit $status
+
diff --git a/gpcontrib/pg_hint_plan/.gitignore b/gpcontrib/pg_hint_plan/.gitignore
new file mode 100644
index 0000000000..d4176bee5a
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/.gitignore
@@ -0,0 +1,15 @@
+# Global excludes across all subdirectories
+*.o
+*.so
+*.bc
+tags
+regression.*
+*.tar.gz
+*~
+
+# Generated subdirectories
+/.deps/
+/log/
+/results/
+/tmp_check/
+/RPMS/
\ No newline at end of file
diff --git a/gpcontrib/pg_hint_plan/COPYRIGHT b/gpcontrib/pg_hint_plan/COPYRIGHT
new file mode 100644
index 0000000000..25d52e00d5
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/COPYRIGHT
@@ -0,0 +1,26 @@
+Copyright (c) 2012-2023, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+    * Neither the name of the NIPPON TELEGRAPH AND TELEPHONE CORPORATION
+      (NTT) nor the names of its contributors may be used to endorse or
+      promote products derived from this software without specific prior
+      written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/gpcontrib/pg_hint_plan/COPYRIGHT.postgresql b/gpcontrib/pg_hint_plan/COPYRIGHT.postgresql
new file mode 100644
index 0000000000..6e1da3ca7b
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/COPYRIGHT.postgresql
@@ -0,0 +1,24 @@
+core.c and make_join_rel.c are parts of PostgreSQL Database Management System.
+(formerly known as Postgres, then as Postgres95)
+Copyright holders of those files are following organizations:
+
+Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+
+Portions Copyright (c) 1994, The Regents of the University of California
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose, without fee, and without a written agreement
+is hereby granted, provided that the above copyright notice and this
+paragraph and the following two paragraphs appear in all copies.
+
+IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
+LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
+DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
+PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
diff --git a/gpcontrib/pg_hint_plan/META.json b/gpcontrib/pg_hint_plan/META.json
new file mode 100644
index 0000000000..3dbeb11aa6
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/META.json
@@ -0,0 +1,45 @@
+{
+  "name": "pg_hint_plan12",
+  "abstract": "Query hints in SQL comments",
+  "description": "This library adds support for query hints in SQL comments in PostgreSQL 12.",
+  "version": "1.3.9",
+  "maintainer": [
+    "Michael Paquier <mi...@paquier.xyz>"
+  ],
+  "license": "bsd",
+  "prereqs": {
+    "runtime": {
+      "requires": {
+        "PostgreSQL": ">= 12.0.0, < 13.0.0"
+      }
+    }
+  },
+  "provides": {
+     "pg_hint_plan": {
+      "abstract": "Query hints in SQL comments",
+      "file": "pg_hint_plan--1.3.0.sql",
+      "docfile": "README.md",
+      "version": "1.3.9"
+     }
+  },
+  "resources": {
+    "bugtracker": {
+      "web": "https://github.com/ossc-db/pg_hint_plan/issues"
+    },
+    "repository": {
+      "url":  "https://github.com/ossc-db/pg_hint_plan.git",
+      "web":  "https://github.com/ossc-db/pg_hint_plan/",
+      "type": "git"
+    }
+  },
+  "meta-spec": {
+    "version": "1.0.0",
+    "url": "https://pgxn.org/meta/spec.txt"
+  },
+  "tags": [
+    "sql",
+    "plan",
+    "performance",
+    "hint"
+  ]
+}
diff --git a/gpcontrib/pg_hint_plan/Makefile b/gpcontrib/pg_hint_plan/Makefile
new file mode 100644
index 0000000000..3116494be0
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/Makefile
@@ -0,0 +1,64 @@
+#
+# pg_hint_plan: Makefile
+#
+# Copyright (c) 2012-2020, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
+#
+
+MODULES = pg_hint_plan
+HINTPLANVER = 1.3.9
+
+REGRESS = init base_plan pg_hint_plan ut-init ut-A ut-S ut-J ut-L ut-G ut-R \
+	ut-fdw ut-W ut-T ut-fini plpgsql oldextversions
+REGRESS_OPTS = --encoding=UTF8
+
+EXTENSION = pg_hint_plan
+DATA = \
+	pg_hint_plan--1.3.0.sql \
+	pg_hint_plan--1.3.0--1.3.1.sql \
+	pg_hint_plan--1.3.1--1.3.2.sql \
+	pg_hint_plan--1.3.2--1.3.3.sql \
+	pg_hint_plan--1.3.3--1.3.4.sql \
+	pg_hint_plan--1.3.5--1.3.6.sql  \
+	pg_hint_plan--1.3.4--1.3.5.sql \
+	pg_hint_plan--1.3.6--1.3.7.sql \
+	pg_hint_plan--1.3.7--1.3.8.sql \
+	pg_hint_plan--1.3.8--1.3.9.sql
+
+EXTRA_CLEAN = sql/ut-fdw.sql expected/ut-fdw.out RPMS
+
+PG_CONFIG = pg_config
+PGXS := $(shell $(PG_CONFIG) --pgxs)
+include $(PGXS)
+
+STARBALL12 = pg_hint_plan12-$(HINTPLANVER).tar.gz
+STARBALLS = $(STARBALL12)
+
+TARSOURCES = Makefile *.c  *.h COPYRIGHT* \
+	pg_hint_plan--*.sql \
+	pg_hint_plan.control \
+	doc/* expected/*.out sql/*.sql sql/maskout.sh \
+	data/data.csv input/*.source output/*.source SPECS/*.spec
+
+ifneq ($(shell uname), SunOS)
+LDFLAGS+=-Wl,--build-id
+endif
+
+rpms: rpm12
+
+# pg_hint_plan.c includes core.c and make_join_rel.c
+pg_hint_plan.o: core.c make_join_rel.c # pg_stat_statements.c
+
+$(STARBALLS): $(TARSOURCES)
+	if [ -h $(subst .tar.gz,,$@) ]; then rm $(subst .tar.gz,,$@); fi
+	if [ -e $(subst .tar.gz,,$@) ]; then \
+	  echo "$(subst .tar.gz,,$@) is not a symlink. Stop."; \
+	  exit 1; \
+	fi
+	ln -s . $(subst .tar.gz,,$@)
+	tar -chzf $@ $(addprefix $(subst .tar.gz,,$@)/, $^)
+	rm $(subst .tar.gz,,$@)
+
+rpm12: $(STARBALL12)
+	MAKE_ROOT=`pwd` rpmbuild -bb SPECS/pg_hint_plan12.spec
+
+
diff --git a/gpcontrib/pg_hint_plan/SPECS/pg_hint_plan12.spec b/gpcontrib/pg_hint_plan/SPECS/pg_hint_plan12.spec
new file mode 100644
index 0000000000..e12ff27cdc
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/SPECS/pg_hint_plan12.spec
@@ -0,0 +1,106 @@
+# SPEC file for pg_store_plans
+# Copyright(C) 2020 NIPPON TELEGRAPH AND TELEPHONE CORPORATION
+
+%define _pgdir   /usr/pgsql-12
+%define _bindir  %{_pgdir}/bin
+%define _libdir  %{_pgdir}/lib
+%define _datadir %{_pgdir}/share
+%define _bcdir %{_libdir}/bitcode
+%define _mybcdir %{_bcdir}/pg_hint_plan
+
+%if "%(echo ${MAKE_ROOT})" != ""
+  %define _rpmdir %(echo ${MAKE_ROOT})/RPMS
+  %define _sourcedir %(echo ${MAKE_ROOT})
+%endif
+
+## Set general information for pg_store_plans.
+Summary:    Optimizer hint on PostgreSQL 12
+Name:       pg_hint_plan12
+Version:    1.3.9
+Release:    1%{?dist}
+License:    BSD
+Group:      Applications/Databases
+Source0:    %{name}-%{version}.tar.gz
+URL:        https://github.com/ossc-db/pg_hint_plan
+BuildRoot:  %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
+Vendor:     NIPPON TELEGRAPH AND TELEPHONE CORPORATION
+
+## We use postgresql-devel package
+BuildRequires:  postgresql12-devel
+Requires:  postgresql12-server
+
+## Description for "pg_hint_plan"
+%description
+
+pg_hint_plan provides capability to tweak execution plans to be
+executed on PostgreSQL.
+
+Note that this package is available for only PostgreSQL 12.
+
+%package llvmjit
+Requires: postgresql12-server, postgresql12-llvmjit
+Requires: pg_hint_plan12 = 1.3.9
+Summary:  Just-in-time compilation support for pg_hint_plan12
+
+%description llvmjit
+Just-in-time compilation support for pg_hint_plan12
+
+## pre work for build pg_hint_plan
+%prep
+PATH=/usr/pgsql-12/bin:$PATH
+if [ "${MAKE_ROOT}" != "" ]; then
+  pushd ${MAKE_ROOT}
+  make clean %{name}-%{version}.tar.gz
+  popd
+fi
+if [ ! -d %{_rpmdir} ]; then mkdir -p %{_rpmdir}; fi
+%setup -q
+
+## Set variables for build environment
+%build
+PATH=/usr/pgsql-12/bin:$PATH
+make USE_PGXS=1 %{?_smp_mflags}
+
+## Set variables for install
+%install
+rm -rf %{buildroot}
+make install DESTDIR=%{buildroot}
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(0755,root,root)
+%{_libdir}/pg_hint_plan.so
+%defattr(0644,root,root)
+%{_datadir}/extension/pg_hint_plan--1.3.0.sql
+%{_datadir}/extension/pg_hint_plan--1.3.0--1.3.1.sql
+%{_datadir}/extension/pg_hint_plan--1.3.1--1.3.2.sql
+%{_datadir}/extension/pg_hint_plan--1.3.2--1.3.3.sql
+%{_datadir}/extension/pg_hint_plan--1.3.3--1.3.4.sql
+%{_datadir}/extension/pg_hint_plan--1.3.4--1.3.5.sql
+%{_datadir}/extension/pg_hint_plan--1.3.5--1.3.6.sql
+%{_datadir}/extension/pg_hint_plan--1.3.6--1.3.7.sql
+%{_datadir}/extension/pg_hint_plan--1.3.7--1.3.8.sql
+%{_datadir}/extension/pg_hint_plan--1.3.8--1.3.9.sql
+%{_datadir}/extension/pg_hint_plan.control
+
+%files llvmjit
+%defattr(0755,root,root)
+%{_mybcdir}
+%defattr(0644,root,root)
+%{_bcdir}/pg_hint_plan.index.bc
+%{_mybcdir}/pg_hint_plan.bc
+
+# History of pg_hint_plan.
+%changelog
+* Tue Aug 29 2023 Michael Paquier
+- Version 1.3.9.
+* Fri Jan 20 2023 Michael Paquier
+- Version 1.3.8.
+* Thu Oct 29 2020 Kyotaro Horiguchi
+- Fix a bug. Version 1.3.7.
+* Wed Aug 5 2020 Kyotaro Horiguchi
+- Fix some bugs. Version 1.3.6.
+* Thu Feb 20 2020 Kyotaro Horiguchi
+- Support PostgreSQL 12. Fix some bugs. Version 1.3.5.
diff --git a/gpcontrib/pg_hint_plan/core.c b/gpcontrib/pg_hint_plan/core.c
new file mode 100644
index 0000000000..fa7baca304
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/core.c
@@ -0,0 +1,1230 @@
+/*-------------------------------------------------------------------------
+ *
+ * core.c
+ *	  Routines copied from PostgreSQL core distribution.
+ *
+ * The main purpose of this files is having access to static functions in core.
+ * Another purpose is tweaking functions behavior by replacing part of them by
+ * macro definitions. See at the end of pg_hint_plan.c for details. Anyway,
+ * this file *must* contain required functions without making any change.
+ *
+ * This file contains the following functions from corresponding files.
+ *
+ * src/backend/optimizer/path/allpaths.c
+ *
+ *  public functions:
+ *     standard_join_search(): This funcion is not static. The reason for
+ *        including this function is make_rels_by_clause_joins. In order to
+ *        avoid generating apparently unwanted join combination, we decided to
+ *        change the behavior of make_join_rel, which is called under this
+ *        function.
+ *
+ *	static functions:
+ *	   set_plain_rel_pathlist()
+ *	   set_append_rel_pathlist()
+ *	   create_plain_partial_paths()
+ *
+ * src/backend/optimizer/path/joinrels.c
+ *
+ *	public functions:
+ *     join_search_one_level(): We have to modify this to call my definition of
+ * 		    make_rels_by_clause_joins.
+ *
+ *	static functions:
+ *     make_rels_by_clause_joins()
+ *     make_rels_by_clauseless_joins()
+ *     join_is_legal()
+ *     has_join_restriction()
+ *     restriction_is_constant_false()
+ *     build_child_join_sjinfo()
+ *     try_partitionwise_join()
+ *
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static void populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
+										RelOptInfo *rel2, RelOptInfo *joinrel,
+										SpecialJoinInfo *sjinfo, List *restrictlist);
+
+/*
+ * set_plain_rel_pathlist
+ *	  Build access paths for a plain relation (no subquery, no inheritance)
+ */
+static void
+set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
+{
+	Relids		required_outer;
+
+	/*
+	 * We don't support pushing join clauses into the quals of a seqscan, but
+	 * it could still have required parameterization due to LATERAL refs in
+	 * its tlist.
+	 */
+	required_outer = rel->lateral_relids;
+
+	/* Consider sequential scan */
+	add_path(rel, create_seqscan_path(root, rel, required_outer, 0));
+
+	/* If appropriate, consider parallel sequential scan */
+	if (rel->consider_parallel && required_outer == NULL)
+		create_plain_partial_paths(root, rel);
+
+	/* Consider index scans */
+	create_index_paths(root, rel);
+
+	/* Consider TID scans */
+	create_tidscan_paths(root, rel);
+}
+
+
+/*
+ * set_append_rel_pathlist
+ *	  Build access paths for an "append relation"
+ */
+static void
+set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
+						Index rti, RangeTblEntry *rte)
+{
+	int			parentRTindex = rti;
+	List	   *live_childrels = NIL;
+	ListCell   *l;
+
+	/*
+	 * Generate access paths for each member relation, and remember the
+	 * non-dummy children.
+	 */
+	foreach(l, root->append_rel_list)
+	{
+		AppendRelInfo *appinfo = (AppendRelInfo *) lfirst(l);
+		int			childRTindex;
+		RangeTblEntry *childRTE;
+		RelOptInfo *childrel;
+
+		/* append_rel_list contains all append rels; ignore others */
+		if (appinfo->parent_relid != parentRTindex)
+			continue;
+
+		/* Re-locate the child RTE and RelOptInfo */
+		childRTindex = appinfo->child_relid;
+		childRTE = root->simple_rte_array[childRTindex];
+		childrel = root->simple_rel_array[childRTindex];
+
+		/*
+		 * If set_append_rel_size() decided the parent appendrel was
+		 * parallel-unsafe at some point after visiting this child rel, we
+		 * need to propagate the unsafety marking down to the child, so that
+		 * we don't generate useless partial paths for it.
+		 */
+		if (!rel->consider_parallel)
+			childrel->consider_parallel = false;
+
+		/*
+		 * Compute the child's access paths.
+		 */
+		set_rel_pathlist(root, childrel, childRTindex, childRTE);
+
+		/*
+		 * If child is dummy, ignore it.
+		 */
+		if (IS_DUMMY_REL(childrel))
+			continue;
+
+		/* Bubble up childrel's partitioned children. */
+		if (rel->part_scheme)
+			rel->partitioned_child_rels =
+				list_concat(rel->partitioned_child_rels,
+							list_copy(childrel->partitioned_child_rels));
+
+		/*
+		 * Child is live, so add it to the live_childrels list for use below.
+		 */
+		live_childrels = lappend(live_childrels, childrel);
+	}
+
+	/* Add paths to the append relation. */
+	add_paths_to_append_rel(root, rel, live_childrels);
+}
+
+
+/*
+ * standard_join_search
+ *	  Find possible joinpaths for a query by successively finding ways
+ *	  to join component relations into join relations.
+ *
+ * 'levels_needed' is the number of iterations needed, ie, the number of
+ *		independent jointree items in the query.  This is > 1.
+ *
+ * 'initial_rels' is a list of RelOptInfo nodes for each independent
+ *		jointree item.  These are the components to be joined together.
+ *		Note that levels_needed == list_length(initial_rels).
+ *
+ * Returns the final level of join relations, i.e., the relation that is
+ * the result of joining all the original relations together.
+ * At least one implementation path must be provided for this relation and
+ * all required sub-relations.
+ *
+ * To support loadable plugins that modify planner behavior by changing the
+ * join searching algorithm, we provide a hook variable that lets a plugin
+ * replace or supplement this function.  Any such hook must return the same
+ * final join relation as the standard code would, but it might have a
+ * different set of implementation paths attached, and only the sub-joinrels
+ * needed for these paths need have been instantiated.
+ *
+ * Note to plugin authors: the functions invoked during standard_join_search()
+ * modify root->join_rel_list and root->join_rel_hash.  If you want to do more
+ * than one join-order search, you'll probably need to save and restore the
+ * original states of those data structures.  See geqo_eval() for an example.
+ */
+RelOptInfo *
+standard_join_search(PlannerInfo *root, int levels_needed, List *initial_rels)
+{
+	int			lev;
+	RelOptInfo *rel;
+
+	/*
+	 * This function cannot be invoked recursively within any one planning
+	 * problem, so join_rel_level[] can't be in use already.
+	 */
+	Assert(root->join_rel_level == NULL);
+
+	/*
+	 * We employ a simple "dynamic programming" algorithm: we first find all
+	 * ways to build joins of two jointree items, then all ways to build joins
+	 * of three items (from two-item joins and single items), then four-item
+	 * joins, and so on until we have considered all ways to join all the
+	 * items into one rel.
+	 *
+	 * root->join_rel_level[j] is a list of all the j-item rels.  Initially we
+	 * set root->join_rel_level[1] to represent all the single-jointree-item
+	 * relations.
+	 */
+	root->join_rel_level = (List **) palloc0((levels_needed + 1) * sizeof(List *));
+
+	root->join_rel_level[1] = initial_rels;
+
+	for (lev = 2; lev <= levels_needed; lev++)
+	{
+		ListCell   *lc;
+
+		/*
+		 * Determine all possible pairs of relations to be joined at this
+		 * level, and build paths for making each one from every available
+		 * pair of lower-level relations.
+		 */
+		join_search_one_level(root, lev);
+
+		/*
+		 * Run generate_partitionwise_join_paths() and generate_gather_paths()
+		 * for each just-processed joinrel.  We could not do this earlier
+		 * because both regular and partial paths can get added to a
+		 * particular joinrel at multiple times within join_search_one_level.
+		 *
+		 * After that, we're done creating paths for the joinrel, so run
+		 * set_cheapest().
+		 */
+		foreach(lc, root->join_rel_level[lev])
+		{
+			rel = (RelOptInfo *) lfirst(lc);
+
+			/* Create paths for partitionwise joins. */
+			generate_partitionwise_join_paths(root, rel);
+
+			/*
+			 * Except for the topmost scan/join rel, consider gathering
+			 * partial paths.  We'll do the same for the topmost scan/join rel
+			 * once we know the final targetlist (see grouping_planner).
+			 */
+			if (lev < levels_needed)
+				generate_gather_paths(root, rel, false);
+
+			/* Find and save the cheapest paths for this rel */
+			set_cheapest(rel);
+
+#ifdef OPTIMIZER_DEBUG
+			debug_print_rel(root, rel);
+#endif
+		}
+	}
+
+	/*
+	 * We should have a single rel at the final level.
+	 */
+	if (root->join_rel_level[levels_needed] == NIL)
+		elog(ERROR, "failed to build any %d-way joins", levels_needed);
+	Assert(list_length(root->join_rel_level[levels_needed]) == 1);
+
+	rel = (RelOptInfo *) linitial(root->join_rel_level[levels_needed]);
+
+	root->join_rel_level = NULL;
+
+	return rel;
+}
+
+
+/*
+ * create_plain_partial_paths
+ *	  Build partial access paths for parallel scan of a plain relation
+ */
+static void
+create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
+{
+	int			parallel_workers;
+
+	parallel_workers = compute_parallel_worker(rel, rel->pages, -1,
+											   max_parallel_workers_per_gather);
+
+	/* If any limit was set to zero, the user doesn't want a parallel scan. */
+	if (parallel_workers <= 0)
+		return;
+
+	/* Add an unordered partial path based on a parallel sequential scan. */
+	add_partial_path(rel, create_seqscan_path(root, rel, NULL, parallel_workers));
+}
+
+
+/*
+ * join_search_one_level
+ *	  Consider ways to produce join relations containing exactly 'level'
+ *	  jointree items.  (This is one step of the dynamic-programming method
+ *	  embodied in standard_join_search.)  Join rel nodes for each feasible
+ *	  combination of lower-level rels are created and returned in a list.
+ *	  Implementation paths are created for each such joinrel, too.
+ *
+ * level: level of rels we want to make this time
+ * root->join_rel_level[j], 1 <= j < level, is a list of rels containing j items
+ *
+ * The result is returned in root->join_rel_level[level].
+ */
+void
+join_search_one_level(PlannerInfo *root, int level)
+{
+	List	  **joinrels = root->join_rel_level;
+	ListCell   *r;
+	int			k;
+
+	Assert(joinrels[level] == NIL);
+
+	/* Set join_cur_level so that new joinrels are added to proper list */
+	root->join_cur_level = level;
+
+	/*
+	 * First, consider left-sided and right-sided plans, in which rels of
+	 * exactly level-1 member relations are joined against initial relations.
+	 * We prefer to join using join clauses, but if we find a rel of level-1
+	 * members that has no join clauses, we will generate Cartesian-product
+	 * joins against all initial rels not already contained in it.
+	 */
+	foreach(r, joinrels[level - 1])
+	{
+		RelOptInfo *old_rel = (RelOptInfo *) lfirst(r);
+
+		if (old_rel->joininfo != NIL || old_rel->has_eclass_joins ||
+			has_join_restriction(root, old_rel))
+		{
+			/*
+			 * There are join clauses or join order restrictions relevant to
+			 * this rel, so consider joins between this rel and (only) those
+			 * initial rels it is linked to by a clause or restriction.
+			 *
+			 * At level 2 this condition is symmetric, so there is no need to
+			 * look at initial rels before this one in the list; we already
+			 * considered such joins when we were at the earlier rel.  (The
+			 * mirror-image joins are handled automatically by make_join_rel.)
+			 * In later passes (level > 2), we join rels of the previous level
+			 * to each initial rel they don't already include but have a join
+			 * clause or restriction with.
+			 */
+			ListCell   *other_rels;
+
+			if (level == 2)		/* consider remaining initial rels */
+				other_rels = lnext(r);
+			else				/* consider all initial rels */
+				other_rels = list_head(joinrels[1]);
+
+			make_rels_by_clause_joins(root,
+									  old_rel,
+									  other_rels);
+		}
+		else
+		{
+			/*
+			 * Oops, we have a relation that is not joined to any other
+			 * relation, either directly or by join-order restrictions.
+			 * Cartesian product time.
+			 *
+			 * We consider a cartesian product with each not-already-included
+			 * initial rel, whether it has other join clauses or not.  At
+			 * level 2, if there are two or more clauseless initial rels, we
+			 * will redundantly consider joining them in both directions; but
+			 * such cases aren't common enough to justify adding complexity to
+			 * avoid the duplicated effort.
+			 */
+			make_rels_by_clauseless_joins(root,
+										  old_rel,
+										  list_head(joinrels[1]));
+		}
+	}
+
+	/*
+	 * Now, consider "bushy plans" in which relations of k initial rels are
+	 * joined to relations of level-k initial rels, for 2 <= k <= level-2.
+	 *
+	 * We only consider bushy-plan joins for pairs of rels where there is a
+	 * suitable join clause (or join order restriction), in order to avoid
+	 * unreasonable growth of planning time.
+	 */
+	for (k = 2;; k++)
+	{
+		int			other_level = level - k;
+
+		/*
+		 * Since make_join_rel(x, y) handles both x,y and y,x cases, we only
+		 * need to go as far as the halfway point.
+		 */
+		if (k > other_level)
+			break;
+
+		foreach(r, joinrels[k])
+		{
+			RelOptInfo *old_rel = (RelOptInfo *) lfirst(r);
+			ListCell   *other_rels;
+			ListCell   *r2;
+
+			/*
+			 * We can ignore relations without join clauses here, unless they
+			 * participate in join-order restrictions --- then we might have
+			 * to force a bushy join plan.
+			 */
+			if (old_rel->joininfo == NIL && !old_rel->has_eclass_joins &&
+				!has_join_restriction(root, old_rel))
+				continue;
+
+			if (k == other_level)
+				other_rels = lnext(r);	/* only consider remaining rels */
+			else
+				other_rels = list_head(joinrels[other_level]);
+
+			for_each_cell(r2, other_rels)
+			{
+				RelOptInfo *new_rel = (RelOptInfo *) lfirst(r2);
+
+				if (!bms_overlap(old_rel->relids, new_rel->relids))
+				{
+					/*
+					 * OK, we can build a rel of the right level from this
+					 * pair of rels.  Do so if there is at least one relevant
+					 * join clause or join order restriction.
+					 */
+					if (have_relevant_joinclause(root, old_rel, new_rel) ||
+						have_join_order_restriction(root, old_rel, new_rel))
+					{
+						(void) make_join_rel(root, old_rel, new_rel);
+					}
+				}
+			}
+		}
+	}
+
+	/*----------
+	 * Last-ditch effort: if we failed to find any usable joins so far, force
+	 * a set of cartesian-product joins to be generated.  This handles the
+	 * special case where all the available rels have join clauses but we
+	 * cannot use any of those clauses yet.  This can only happen when we are
+	 * considering a join sub-problem (a sub-joinlist) and all the rels in the
+	 * sub-problem have only join clauses with rels outside the sub-problem.
+	 * An example is
+	 *
+	 *		SELECT ... FROM a INNER JOIN b ON TRUE, c, d, ...
+	 *		WHERE a.w = c.x and b.y = d.z;
+	 *
+	 * If the "a INNER JOIN b" sub-problem does not get flattened into the
+	 * upper level, we must be willing to make a cartesian join of a and b;
+	 * but the code above will not have done so, because it thought that both
+	 * a and b have joinclauses.  We consider only left-sided and right-sided
+	 * cartesian joins in this case (no bushy).
+	 *----------
+	 */
+	if (joinrels[level] == NIL)
+	{
+		/*
+		 * This loop is just like the first one, except we always call
+		 * make_rels_by_clauseless_joins().
+		 */
+		foreach(r, joinrels[level - 1])
+		{
+			RelOptInfo *old_rel = (RelOptInfo *) lfirst(r);
+
+			make_rels_by_clauseless_joins(root,
+										  old_rel,
+										  list_head(joinrels[1]));
+		}
+
+		/*----------
+		 * When special joins are involved, there may be no legal way
+		 * to make an N-way join for some values of N.  For example consider
+		 *
+		 * SELECT ... FROM t1 WHERE
+		 *	 x IN (SELECT ... FROM t2,t3 WHERE ...) AND
+		 *	 y IN (SELECT ... FROM t4,t5 WHERE ...)
+		 *
+		 * We will flatten this query to a 5-way join problem, but there are
+		 * no 4-way joins that join_is_legal() will consider legal.  We have
+		 * to accept failure at level 4 and go on to discover a workable
+		 * bushy plan at level 5.
+		 *
+		 * However, if there are no special joins and no lateral references
+		 * then join_is_legal() should never fail, and so the following sanity
+		 * check is useful.
+		 *----------
+		 */
+		if (joinrels[level] == NIL &&
+			root->join_info_list == NIL &&
+			!root->hasLateralRTEs)
+			elog(ERROR, "failed to build any %d-way joins", level);
+	}
+}
+
+
+/*
+ * make_rels_by_clause_joins
+ *	  Build joins between the given relation 'old_rel' and other relations
+ *	  that participate in join clauses that 'old_rel' also participates in
+ *	  (or participate in join-order restrictions with it).
+ *	  The join rels are returned in root->join_rel_level[join_cur_level].
+ *
+ * Note: at levels above 2 we will generate the same joined relation in
+ * multiple ways --- for example (a join b) join c is the same RelOptInfo as
+ * (b join c) join a, though the second case will add a different set of Paths
+ * to it.  This is the reason for using the join_rel_level mechanism, which
+ * automatically ensures that each new joinrel is only added to the list once.
+ *
+ * 'old_rel' is the relation entry for the relation to be joined
+ * 'other_rels': the first cell in a linked list containing the other
+ * rels to be considered for joining
+ *
+ * Currently, this is only used with initial rels in other_rels, but it
+ * will work for joining to joinrels too.
+ */
+static void
+make_rels_by_clause_joins(PlannerInfo *root,
+						  RelOptInfo *old_rel,
+						  ListCell *other_rels)
+{
+	ListCell   *l;
+
+	for_each_cell(l, other_rels)
+	{
+		RelOptInfo *other_rel = (RelOptInfo *) lfirst(l);
+
+		if (!bms_overlap(old_rel->relids, other_rel->relids) &&
+			(have_relevant_joinclause(root, old_rel, other_rel) ||
+			 have_join_order_restriction(root, old_rel, other_rel)))
+		{
+			(void) make_join_rel(root, old_rel, other_rel);
+		}
+	}
+}
+
+
+/*
+ * make_rels_by_clauseless_joins
+ *	  Given a relation 'old_rel' and a list of other relations
+ *	  'other_rels', create a join relation between 'old_rel' and each
+ *	  member of 'other_rels' that isn't already included in 'old_rel'.
+ *	  The join rels are returned in root->join_rel_level[join_cur_level].
+ *
+ * 'old_rel' is the relation entry for the relation to be joined
+ * 'other_rels': the first cell of a linked list containing the
+ * other rels to be considered for joining
+ *
+ * Currently, this is only used with initial rels in other_rels, but it would
+ * work for joining to joinrels too.
+ */
+static void
+make_rels_by_clauseless_joins(PlannerInfo *root,
+							  RelOptInfo *old_rel,
+							  ListCell *other_rels)
+{
+	ListCell   *l;
+
+	for_each_cell(l, other_rels)
+	{
+		RelOptInfo *other_rel = (RelOptInfo *) lfirst(l);
+
+		if (!bms_overlap(other_rel->relids, old_rel->relids))
+		{
+			(void) make_join_rel(root, old_rel, other_rel);
+		}
+	}
+}
+
+
+/*
+ * join_is_legal
+ *	   Determine whether a proposed join is legal given the query's
+ *	   join order constraints; and if it is, determine the join type.
+ *
+ * Caller must supply not only the two rels, but the union of their relids.
+ * (We could simplify the API by computing joinrelids locally, but this
+ * would be redundant work in the normal path through make_join_rel.)
+ *
+ * On success, *sjinfo_p is set to NULL if this is to be a plain inner join,
+ * else it's set to point to the associated SpecialJoinInfo node.  Also,
+ * *reversed_p is set true if the given relations need to be swapped to
+ * match the SpecialJoinInfo node.
+ */
+static bool
+join_is_legal(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
+			  Relids joinrelids,
+			  SpecialJoinInfo **sjinfo_p, bool *reversed_p)
+{
+	SpecialJoinInfo *match_sjinfo;
+	bool		reversed;
+	bool		unique_ified;
+	bool		must_be_leftjoin;
+	ListCell   *l;
+
+	/*
+	 * Ensure output params are set on failure return.  This is just to
+	 * suppress uninitialized-variable warnings from overly anal compilers.
+	 */
+	*sjinfo_p = NULL;
+	*reversed_p = false;
+
+	/*
+	 * If we have any special joins, the proposed join might be illegal; and
+	 * in any case we have to determine its join type.  Scan the join info
+	 * list for matches and conflicts.
+	 */
+	match_sjinfo = NULL;
+	reversed = false;
+	unique_ified = false;
+	must_be_leftjoin = false;
+
+	foreach(l, root->join_info_list)
+	{
+		SpecialJoinInfo *sjinfo = (SpecialJoinInfo *) lfirst(l);
+
+		/*
+		 * This special join is not relevant unless its RHS overlaps the
+		 * proposed join.  (Check this first as a fast path for dismissing
+		 * most irrelevant SJs quickly.)
+		 */
+		if (!bms_overlap(sjinfo->min_righthand, joinrelids))
+			continue;
+
+		/*
+		 * Also, not relevant if proposed join is fully contained within RHS
+		 * (ie, we're still building up the RHS).
+		 */
+		if (bms_is_subset(joinrelids, sjinfo->min_righthand))
+			continue;
+
+		/*
+		 * Also, not relevant if SJ is already done within either input.
+		 */
+		if (bms_is_subset(sjinfo->min_lefthand, rel1->relids) &&
+			bms_is_subset(sjinfo->min_righthand, rel1->relids))
+			continue;
+		if (bms_is_subset(sjinfo->min_lefthand, rel2->relids) &&
+			bms_is_subset(sjinfo->min_righthand, rel2->relids))
+			continue;
+
+		/*
+		 * If it's a semijoin and we already joined the RHS to any other rels
+		 * within either input, then we must have unique-ified the RHS at that
+		 * point (see below).  Therefore the semijoin is no longer relevant in
+		 * this join path.
+		 */
+		if (sjinfo->jointype == JOIN_SEMI)
+		{
+			if (bms_is_subset(sjinfo->syn_righthand, rel1->relids) &&
+				!bms_equal(sjinfo->syn_righthand, rel1->relids))
+				continue;
+			if (bms_is_subset(sjinfo->syn_righthand, rel2->relids) &&
+				!bms_equal(sjinfo->syn_righthand, rel2->relids))
+				continue;
+		}
+
+		/*
+		 * If one input contains min_lefthand and the other contains
+		 * min_righthand, then we can perform the SJ at this join.
+		 *
+		 * Reject if we get matches to more than one SJ; that implies we're
+		 * considering something that's not really valid.
+		 */
+		if (bms_is_subset(sjinfo->min_lefthand, rel1->relids) &&
+			bms_is_subset(sjinfo->min_righthand, rel2->relids))
+		{
+			if (match_sjinfo)
+				return false;	/* invalid join path */
+			match_sjinfo = sjinfo;
+			reversed = false;
+		}
+		else if (bms_is_subset(sjinfo->min_lefthand, rel2->relids) &&
+				 bms_is_subset(sjinfo->min_righthand, rel1->relids))
+		{
+			if (match_sjinfo)
+				return false;	/* invalid join path */
+			match_sjinfo = sjinfo;
+			reversed = true;
+		}
+		else if (sjinfo->jointype == JOIN_SEMI &&
+				 bms_equal(sjinfo->syn_righthand, rel2->relids) &&
+				 create_unique_path(root, rel2, rel2->cheapest_total_path,
+									sjinfo) != NULL)
+		{
+			/*----------
+			 * For a semijoin, we can join the RHS to anything else by
+			 * unique-ifying the RHS (if the RHS can be unique-ified).
+			 * We will only get here if we have the full RHS but less
+			 * than min_lefthand on the LHS.
+			 *
+			 * The reason to consider such a join path is exemplified by
+			 *	SELECT ... FROM a,b WHERE (a.x,b.y) IN (SELECT c1,c2 FROM c)
+			 * If we insist on doing this as a semijoin we will first have
+			 * to form the cartesian product of A*B.  But if we unique-ify
+			 * C then the semijoin becomes a plain innerjoin and we can join
+			 * in any order, eg C to A and then to B.  When C is much smaller
+			 * than A and B this can be a huge win.  So we allow C to be
+			 * joined to just A or just B here, and then make_join_rel has
+			 * to handle the case properly.
+			 *
+			 * Note that actually we'll allow unique-ified C to be joined to
+			 * some other relation D here, too.  That is legal, if usually not
+			 * very sane, and this routine is only concerned with legality not
+			 * with whether the join is good strategy.
+			 *----------
+			 */
+			if (match_sjinfo)
+				return false;	/* invalid join path */
+			match_sjinfo = sjinfo;
+			reversed = false;
+			unique_ified = true;
+		}
+		else if (sjinfo->jointype == JOIN_SEMI &&
+				 bms_equal(sjinfo->syn_righthand, rel1->relids) &&
+				 create_unique_path(root, rel1, rel1->cheapest_total_path,
+									sjinfo) != NULL)
+		{
+			/* Reversed semijoin case */
+			if (match_sjinfo)
+				return false;	/* invalid join path */
+			match_sjinfo = sjinfo;
+			reversed = true;
+			unique_ified = true;
+		}
+		else
+		{
+			/*
+			 * Otherwise, the proposed join overlaps the RHS but isn't a valid
+			 * implementation of this SJ.  But don't panic quite yet: the RHS
+			 * violation might have occurred previously, in one or both input
+			 * relations, in which case we must have previously decided that
+			 * it was OK to commute some other SJ with this one.  If we need
+			 * to perform this join to finish building up the RHS, rejecting
+			 * it could lead to not finding any plan at all.  (This can occur
+			 * because of the heuristics elsewhere in this file that postpone
+			 * clauseless joins: we might not consider doing a clauseless join
+			 * within the RHS until after we've performed other, validly
+			 * commutable SJs with one or both sides of the clauseless join.)
+			 * This consideration boils down to the rule that if both inputs
+			 * overlap the RHS, we can allow the join --- they are either
+			 * fully within the RHS, or represent previously-allowed joins to
+			 * rels outside it.
+			 */
+			if (bms_overlap(rel1->relids, sjinfo->min_righthand) &&
+				bms_overlap(rel2->relids, sjinfo->min_righthand))
+				continue;		/* assume valid previous violation of RHS */
+
+			/*
+			 * The proposed join could still be legal, but only if we're
+			 * allowed to associate it into the RHS of this SJ.  That means
+			 * this SJ must be a LEFT join (not SEMI or ANTI, and certainly
+			 * not FULL) and the proposed join must not overlap the LHS.
+			 */
+			if (sjinfo->jointype != JOIN_LEFT ||
+				bms_overlap(joinrelids, sjinfo->min_lefthand))
+				return false;	/* invalid join path */
+
+			/*
+			 * To be valid, the proposed join must be a LEFT join; otherwise
+			 * it can't associate into this SJ's RHS.  But we may not yet have
+			 * found the SpecialJoinInfo matching the proposed join, so we
+			 * can't test that yet.  Remember the requirement for later.
+			 */
+			must_be_leftjoin = true;
+		}
+	}
+
+	/*
+	 * Fail if violated any SJ's RHS and didn't match to a LEFT SJ: the
+	 * proposed join can't associate into an SJ's RHS.
+	 *
+	 * Also, fail if the proposed join's predicate isn't strict; we're
+	 * essentially checking to see if we can apply outer-join identity 3, and
+	 * that's a requirement.  (This check may be redundant with checks in
+	 * make_outerjoininfo, but I'm not quite sure, and it's cheap to test.)
+	 */
+	if (must_be_leftjoin &&
+		(match_sjinfo == NULL ||
+		 match_sjinfo->jointype != JOIN_LEFT ||
+		 !match_sjinfo->lhs_strict))
+		return false;			/* invalid join path */
+
+	/*
+	 * We also have to check for constraints imposed by LATERAL references.
+	 */
+	if (root->hasLateralRTEs)
+	{
+		bool		lateral_fwd;
+		bool		lateral_rev;
+		Relids		join_lateral_rels;
+
+		/*
+		 * The proposed rels could each contain lateral references to the
+		 * other, in which case the join is impossible.  If there are lateral
+		 * references in just one direction, then the join has to be done with
+		 * a nestloop with the lateral referencer on the inside.  If the join
+		 * matches an SJ that cannot be implemented by such a nestloop, the
+		 * join is impossible.
+		 *
+		 * Also, if the lateral reference is only indirect, we should reject
+		 * the join; whatever rel(s) the reference chain goes through must be
+		 * joined to first.
+		 *
+		 * Another case that might keep us from building a valid plan is the
+		 * implementation restriction described by have_dangerous_phv().
+		 */
+		lateral_fwd = bms_overlap(rel1->relids, rel2->lateral_relids);
+		lateral_rev = bms_overlap(rel2->relids, rel1->lateral_relids);
+		if (lateral_fwd && lateral_rev)
+			return false;		/* have lateral refs in both directions */
+		if (lateral_fwd)
+		{
+			/* has to be implemented as nestloop with rel1 on left */
+			if (match_sjinfo &&
+				(reversed ||
+				 unique_ified ||
+				 match_sjinfo->jointype == JOIN_FULL))
+				return false;	/* not implementable as nestloop */
+			/* check there is a direct reference from rel2 to rel1 */
+			if (!bms_overlap(rel1->relids, rel2->direct_lateral_relids))
+				return false;	/* only indirect refs, so reject */
+			/* check we won't have a dangerous PHV */
+			if (have_dangerous_phv(root, rel1->relids, rel2->lateral_relids))
+				return false;	/* might be unable to handle required PHV */
+		}
+		else if (lateral_rev)
+		{
+			/* has to be implemented as nestloop with rel2 on left */
+			if (match_sjinfo &&
+				(!reversed ||
+				 unique_ified ||
+				 match_sjinfo->jointype == JOIN_FULL))
+				return false;	/* not implementable as nestloop */
+			/* check there is a direct reference from rel1 to rel2 */
+			if (!bms_overlap(rel2->relids, rel1->direct_lateral_relids))
+				return false;	/* only indirect refs, so reject */
+			/* check we won't have a dangerous PHV */
+			if (have_dangerous_phv(root, rel2->relids, rel1->lateral_relids))
+				return false;	/* might be unable to handle required PHV */
+		}
+
+		/*
+		 * LATERAL references could also cause problems later on if we accept
+		 * this join: if the join's minimum parameterization includes any rels
+		 * that would have to be on the inside of an outer join with this join
+		 * rel, then it's never going to be possible to build the complete
+		 * query using this join.  We should reject this join not only because
+		 * it'll save work, but because if we don't, the clauseless-join
+		 * heuristics might think that legality of this join means that some
+		 * other join rel need not be formed, and that could lead to failure
+		 * to find any plan at all.  We have to consider not only rels that
+		 * are directly on the inner side of an OJ with the joinrel, but also
+		 * ones that are indirectly so, so search to find all such rels.
+		 */
+		join_lateral_rels = min_join_parameterization(root, joinrelids,
+													  rel1, rel2);
+		if (join_lateral_rels)
+		{
+			Relids		join_plus_rhs = bms_copy(joinrelids);
+			bool		more;
+
+			do
+			{
+				more = false;
+				foreach(l, root->join_info_list)
+				{
+					SpecialJoinInfo *sjinfo = (SpecialJoinInfo *) lfirst(l);
+
+					/* ignore full joins --- their ordering is predetermined */
+					if (sjinfo->jointype == JOIN_FULL)
+						continue;
+
+					if (bms_overlap(sjinfo->min_lefthand, join_plus_rhs) &&
+						!bms_is_subset(sjinfo->min_righthand, join_plus_rhs))
+					{
+						join_plus_rhs = bms_add_members(join_plus_rhs,
+														sjinfo->min_righthand);
+						more = true;
+					}
+				}
+			} while (more);
+			if (bms_overlap(join_plus_rhs, join_lateral_rels))
+				return false;	/* will not be able to join to some RHS rel */
+		}
+	}
+
+	/* Otherwise, it's a valid join */
+	*sjinfo_p = match_sjinfo;
+	*reversed_p = reversed;
+	return true;
+}
+
+
+/*
+ * has_join_restriction
+ *		Detect whether the specified relation has join-order restrictions,
+ *		due to being inside an outer join or an IN (sub-SELECT),
+ *		or participating in any LATERAL references or multi-rel PHVs.
+ *
+ * Essentially, this tests whether have_join_order_restriction() could
+ * succeed with this rel and some other one.  It's OK if we sometimes
+ * say "true" incorrectly.  (Therefore, we don't bother with the relatively
+ * expensive has_legal_joinclause test.)
+ */
+static bool
+has_join_restriction(PlannerInfo *root, RelOptInfo *rel)
+{
+	ListCell   *l;
+
+	if (rel->lateral_relids != NULL || rel->lateral_referencers != NULL)
+		return true;
+
+	foreach(l, root->placeholder_list)
+	{
+		PlaceHolderInfo *phinfo = (PlaceHolderInfo *) lfirst(l);
+
+		if (bms_is_subset(rel->relids, phinfo->ph_eval_at) &&
+			!bms_equal(rel->relids, phinfo->ph_eval_at))
+			return true;
+	}
+
+	foreach(l, root->join_info_list)
+	{
+		SpecialJoinInfo *sjinfo = (SpecialJoinInfo *) lfirst(l);
+
+		/* ignore full joins --- other mechanisms preserve their ordering */
+		if (sjinfo->jointype == JOIN_FULL)
+			continue;
+
+		/* ignore if SJ is already contained in rel */
+		if (bms_is_subset(sjinfo->min_lefthand, rel->relids) &&
+			bms_is_subset(sjinfo->min_righthand, rel->relids))
+			continue;
+
+		/* restricted if it overlaps LHS or RHS, but doesn't contain SJ */
+		if (bms_overlap(sjinfo->min_lefthand, rel->relids) ||
+			bms_overlap(sjinfo->min_righthand, rel->relids))
+			return true;
+	}
+
+	return false;
+}
+
+
+/*
+ * restriction_is_constant_false --- is a restrictlist just FALSE?
+ *
+ * In cases where a qual is provably constant FALSE, eval_const_expressions
+ * will generally have thrown away anything that's ANDed with it.  In outer
+ * join situations this will leave us computing cartesian products only to
+ * decide there's no match for an outer row, which is pretty stupid.  So,
+ * we need to detect the case.
+ *
+ * If only_pushed_down is true, then consider only quals that are pushed-down
+ * from the point of view of the joinrel.
+ */
+static bool
+restriction_is_constant_false(List *restrictlist,
+							  RelOptInfo *joinrel,
+							  bool only_pushed_down)
+{
+	ListCell   *lc;
+
+	/*
+	 * Despite the above comment, the restriction list we see here might
+	 * possibly have other members besides the FALSE constant, since other
+	 * quals could get "pushed down" to the outer join level.  So we check
+	 * each member of the list.
+	 */
+	foreach(lc, restrictlist)
+	{
+		RestrictInfo *rinfo = lfirst_node(RestrictInfo, lc);
+
+		if (only_pushed_down && !RINFO_IS_PUSHED_DOWN(rinfo, joinrel->relids))
+			continue;
+
+		if (rinfo->clause && IsA(rinfo->clause, Const))
+		{
+			Const	   *con = (Const *) rinfo->clause;
+
+			/* constant NULL is as good as constant FALSE for our purposes */
+			if (con->constisnull)
+				return true;
+			if (!DatumGetBool(con->constvalue))
+				return true;
+		}
+	}
+	return false;
+}
+
+
+/*
+ * Construct the SpecialJoinInfo for a child-join by translating
+ * SpecialJoinInfo for the join between parents. left_relids and right_relids
+ * are the relids of left and right side of the join respectively.
+ */
+static SpecialJoinInfo *
+build_child_join_sjinfo(PlannerInfo *root, SpecialJoinInfo *parent_sjinfo,
+						Relids left_relids, Relids right_relids)
+{
+	SpecialJoinInfo *sjinfo = makeNode(SpecialJoinInfo);
+	AppendRelInfo **left_appinfos;
+	int			left_nappinfos;
+	AppendRelInfo **right_appinfos;
+	int			right_nappinfos;
+
+	memcpy(sjinfo, parent_sjinfo, sizeof(SpecialJoinInfo));
+	left_appinfos = find_appinfos_by_relids(root, left_relids,
+											&left_nappinfos);
+	right_appinfos = find_appinfos_by_relids(root, right_relids,
+											 &right_nappinfos);
+
+	sjinfo->min_lefthand = adjust_child_relids(sjinfo->min_lefthand,
+											   left_nappinfos, left_appinfos);
+	sjinfo->min_righthand = adjust_child_relids(sjinfo->min_righthand,
+												right_nappinfos,
+												right_appinfos);
+	sjinfo->syn_lefthand = adjust_child_relids(sjinfo->syn_lefthand,
+											   left_nappinfos, left_appinfos);
+	sjinfo->syn_righthand = adjust_child_relids(sjinfo->syn_righthand,
+												right_nappinfos,
+												right_appinfos);
+	sjinfo->semi_rhs_exprs = (List *) adjust_appendrel_attrs(root,
+															 (Node *) sjinfo->semi_rhs_exprs,
+															 right_nappinfos,
+															 right_appinfos);
+
+	pfree(left_appinfos);
+	pfree(right_appinfos);
+
+	return sjinfo;
+}
+
+
+/*
+ * Assess whether join between given two partitioned relations can be broken
+ * down into joins between matching partitions; a technique called
+ * "partitionwise join"
+ *
+ * Partitionwise join is possible when a. Joining relations have same
+ * partitioning scheme b. There exists an equi-join between the partition keys
+ * of the two relations.
+ *
+ * Partitionwise join is planned as follows (details: optimizer/README.)
+ *
+ * 1. Create the RelOptInfos for joins between matching partitions i.e
+ * child-joins and add paths to them.
+ *
+ * 2. Construct Append or MergeAppend paths across the set of child joins.
+ * This second phase is implemented by generate_partitionwise_join_paths().
+ *
+ * The RelOptInfo, SpecialJoinInfo and restrictlist for each child join are
+ * obtained by translating the respective parent join structures.
+ */
+static void
+try_partitionwise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
+					   RelOptInfo *joinrel, SpecialJoinInfo *parent_sjinfo,
+					   List *parent_restrictlist)
+{
+	bool		rel1_is_simple = IS_SIMPLE_REL(rel1);
+	bool		rel2_is_simple = IS_SIMPLE_REL(rel2);
+	int			nparts;
+	int			cnt_parts;
+
+	/* Guard against stack overflow due to overly deep partition hierarchy. */
+	check_stack_depth();
+
+	/* Nothing to do, if the join relation is not partitioned. */
+	if (!IS_PARTITIONED_REL(joinrel))
+		return;
+
+	/* The join relation should have consider_partitionwise_join set. */
+	Assert(joinrel->consider_partitionwise_join);
+
+	/*
+	 * Since this join relation is partitioned, all the base relations
+	 * participating in this join must be partitioned and so are all the
+	 * intermediate join relations.
+	 */
+	Assert(IS_PARTITIONED_REL(rel1) && IS_PARTITIONED_REL(rel2));
+	Assert(REL_HAS_ALL_PART_PROPS(rel1) && REL_HAS_ALL_PART_PROPS(rel2));
+
+	/* The joining relations should have consider_partitionwise_join set. */
+	Assert(rel1->consider_partitionwise_join &&
+		   rel2->consider_partitionwise_join);
+
+	/*
+	 * The partition scheme of the join relation should match that of the
+	 * joining relations.
+	 */
+	Assert(joinrel->part_scheme == rel1->part_scheme &&
+		   joinrel->part_scheme == rel2->part_scheme);
+
+	/*
+	 * Since we allow partitionwise join only when the partition bounds of the
+	 * joining relations exactly match, the partition bounds of the join
+	 * should match those of the joining relations.
+	 */
+	Assert(partition_bounds_equal(joinrel->part_scheme->partnatts,
+								  joinrel->part_scheme->parttyplen,
+								  joinrel->part_scheme->parttypbyval,
+								  joinrel->boundinfo, rel1->boundinfo));
+	Assert(partition_bounds_equal(joinrel->part_scheme->partnatts,
+								  joinrel->part_scheme->parttyplen,
+								  joinrel->part_scheme->parttypbyval,
+								  joinrel->boundinfo, rel2->boundinfo));
+
+	nparts = joinrel->nparts;
+
+	/*
+	 * Create child-join relations for this partitioned join, if those don't
+	 * exist. Add paths to child-joins for a pair of child relations
+	 * corresponding to the given pair of parent relations.
+	 */
+	for (cnt_parts = 0; cnt_parts < nparts; cnt_parts++)
+	{
+		RelOptInfo *child_rel1 = rel1->part_rels[cnt_parts];
+		RelOptInfo *child_rel2 = rel2->part_rels[cnt_parts];
+		bool		rel1_empty = (child_rel1 == NULL ||
+								  IS_DUMMY_REL(child_rel1));
+		bool		rel2_empty = (child_rel2 == NULL ||
+								  IS_DUMMY_REL(child_rel2));
+		SpecialJoinInfo *child_sjinfo;
+		List	   *child_restrictlist;
+		RelOptInfo *child_joinrel;
+		Relids		child_joinrelids;
+		AppendRelInfo **appinfos;
+		int			nappinfos;
+
+		/*
+		 * Check for cases where we can prove that this segment of the join
+		 * returns no rows, due to one or both inputs being empty (including
+		 * inputs that have been pruned away entirely).  If so just ignore it.
+		 * These rules are equivalent to populate_joinrel_with_paths's rules
+		 * for dummy input relations.
+		 */
+		switch (parent_sjinfo->jointype)
+		{
+			case JOIN_INNER:
+			case JOIN_SEMI:
+				if (rel1_empty || rel2_empty)
+					continue;	/* ignore this join segment */
+				break;
+			case JOIN_LEFT:
+			case JOIN_ANTI:
+				if (rel1_empty)
+					continue;	/* ignore this join segment */
+				break;
+			case JOIN_FULL:
+				if (rel1_empty && rel2_empty)
+					continue;	/* ignore this join segment */
+				break;
+			default:
+				/* other values not expected here */
+				elog(ERROR, "unrecognized join type: %d",
+					 (int) parent_sjinfo->jointype);
+				break;
+		}
+
+		/*
+		 * If a child has been pruned entirely then we can't generate paths
+		 * for it, so we have to reject partitionwise joining unless we were
+		 * able to eliminate this partition above.
+		 */
+		if (child_rel1 == NULL || child_rel2 == NULL)
+		{
+			/*
+			 * Mark the joinrel as unpartitioned so that later functions treat
+			 * it correctly.
+			 */
+			joinrel->nparts = 0;
+			return;
+		}
+
+		/*
+		 * If a leaf relation has consider_partitionwise_join=false, it means
+		 * that it's a dummy relation for which we skipped setting up tlist
+		 * expressions and adding EC members in set_append_rel_size(), so
+		 * again we have to fail here.
+		 */
+		if (rel1_is_simple && !child_rel1->consider_partitionwise_join)
+		{
+			Assert(child_rel1->reloptkind == RELOPT_OTHER_MEMBER_REL);
+			Assert(IS_DUMMY_REL(child_rel1));
+			joinrel->nparts = 0;
+			return;
+		}
+		if (rel2_is_simple && !child_rel2->consider_partitionwise_join)
+		{
+			Assert(child_rel2->reloptkind == RELOPT_OTHER_MEMBER_REL);
+			Assert(IS_DUMMY_REL(child_rel2));
+			joinrel->nparts = 0;
+			return;
+		}
+
+		/* We should never try to join two overlapping sets of rels. */
+		Assert(!bms_overlap(child_rel1->relids, child_rel2->relids));
+		child_joinrelids = bms_union(child_rel1->relids, child_rel2->relids);
+		appinfos = find_appinfos_by_relids(root, child_joinrelids, &nappinfos);
+
+		/*
+		 * Construct SpecialJoinInfo from parent join relations's
+		 * SpecialJoinInfo.
+		 */
+		child_sjinfo = build_child_join_sjinfo(root, parent_sjinfo,
+											   child_rel1->relids,
+											   child_rel2->relids);
+
+		/*
+		 * Construct restrictions applicable to the child join from those
+		 * applicable to the parent join.
+		 */
+		child_restrictlist =
+			(List *) adjust_appendrel_attrs(root,
+											(Node *) parent_restrictlist,
+											nappinfos, appinfos);
+		pfree(appinfos);
+
+		child_joinrel = joinrel->part_rels[cnt_parts];
+		if (!child_joinrel)
+		{
+			child_joinrel = build_child_join_rel(root, child_rel1, child_rel2,
+												 joinrel, child_restrictlist,
+												 child_sjinfo,
+												 child_sjinfo->jointype);
+			joinrel->part_rels[cnt_parts] = child_joinrel;
+		}
+
+		Assert(bms_equal(child_joinrel->relids, child_joinrelids));
+
+		populate_joinrel_with_paths(root, child_rel1, child_rel2,
+									child_joinrel, child_sjinfo,
+									child_restrictlist);
+	}
+}
diff --git a/gpcontrib/pg_hint_plan/data/data.csv b/gpcontrib/pg_hint_plan/data/data.csv
new file mode 100644
index 0000000000..43006b3cd5
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/data/data.csv
@@ -0,0 +1,10 @@
+1,1
+2,2
+3,3
+4,4
+5,5
+6,6
+7,7
+8,8
+9,9
+10,10
diff --git a/gpcontrib/pg_hint_plan/doc/hint_list-ja.html b/gpcontrib/pg_hint_plan/doc/hint_list-ja.html
new file mode 100755
index 0000000000..d349af2825
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/doc/hint_list-ja.html
@@ -0,0 +1,113 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD html 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<title>Appendix A. ヒント句一覧</title>
+<!-- Uncoment after the tool has been hosted somewhere.
+<link rel="home" title="pg_hint_plan" href="index.html">
+-->
+<link rel="stylesheet" type="text/css" href="style.css">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+</head>
+
+<body>
+<h1 id="pg_hint_plan">pg_hint_plan 1.3 付録</h1>
+<div class="navigation">
+  <a href="pg_hint_plan-ja.html">pg_hint_plan</a> &gt;
+  <a href="hint_list-ja.html">Appendix A. ヒント句一覧</a>
+</div>
+<hr>
+
+<h2 id="hint-list">Appendix A. ヒント句一覧</h2>
+<p>pg_hint_planで指定できるヒント句は以下の通りです。</p>
+<table>
+<thead>
+<tr>
+<tr><th>グループ</th><th>ヒント句の書式</th><th>説明</th></tr>
+</tr>
+</thead>
+<tbody>
+<tr><td rowspan="11" nowrap>スキャン方式</td>
+  <td nowrap>SeqScan(テーブル)</td>
+  <td>指定したテーブルについて、Seq Scanを選択します。</td></tr>
+<tr><td nowrap>TidScan(テーブル)</td>
+  <td>指定したテーブルについて、Tid Scanを選択します。検索条件にctidを指定した場合にのみ有効です。</td></tr>
+<tr><td nowrap>IndexScan(テーブル[ インデックス...])</td>
+  <td>指定したテーブルについて、Index Scanを選択します。インデックスも指定した場合は、指定したインデックスの中でコストが最小となるIndex Scanを選択します。ただし、インデックスが存在しない場合や指定したインデックスがWHERE句やJOIN条件などに関連しない場合はSeq Scanを選択します。<br>
+継承関係の親テーブルとそのテーブルのインデックスを指定した場合は、子テーブルに対してそのインデックスと同様の定義のインデックスを選択します。</td></tr>
+<tr><td nowrap>IndexOnlyScan(テーブル[ インデックス...])</td>
+  <td>指定したテーブルについて、Index Only ScanとIndex Scanのうちコストが最小となるスキャン方式を選択します。インデックスも指定した場合は、指定したインデックスの中でIndex Only ScanとIndex Scanのうちコストが最小となるスキャン方式を選択します。ただし、インデックスが存在しない場合や指定したインデックスがWHERE句やJOIN条件などに関連しない場合はSeq Scanを選択します。また、これらの場合以外にも、インデックスが持つ値だけでなくテーブルの値も必要な場合はIndex Scanを選択します。<br>
+継承関係の親テーブルとそのテーブルのインデックスを指定した場合は、子テーブルに対してそのインデックスと同様の定義のインデックスを選択します。
+PostgreSQL 9.2以降で動作します。</td></tr>
+<tr><td nowrap>BitmapScan(テーブル[ インデックス...])</td>
+  <td>指定したテーブルについて、Bitmap Scanを選択します。インデックスも指定した場合は、指定したインデックスの中でコストが最小となるインデックスを選択します。ただし、インデックスが存在しない場合や指定したインデックスがWHERE句やJOIN条件などに関連しない場合はSeq Scanを選択します。<br>
+継承関係の親テーブルとそのテーブルのインデックスを指定した場合は、子テーブルに対してそのインデックスと同様の定義のインデックスを選択します。</td></tr>
+<tr><td nowrap>IndexScanRegexp(テーブル[ POSIX正規表現...])</br>IndexOnlyScanRegexp(テーブル[ POSIX正規表現...])</br>BitmapScanRegexp(テーブル[ POSIX正規表現...])</td>
+  <td>テーブルのみを指定した場合のスキャン方式の選択基準は、Regexpの付かないスキャン方式のヒントと同じです。<a href="http://www.postgresql.jp/document/current/html/functions-matching.html#FUNCTIONS-POSIX-REGEXP">POSIX正規表現</a>も指定した場合は、指定したPOSIX正規表現パターンに一致するインデックスの中でコストが最小となるスキャン方式を選択します。指定したテーブルが継承テーブルの場合は、子テーブルについても同じ基準で、使用するインデックスとスキャン方式を選択します。IndexOnlyScanRegexpヒントはPostgreSQL 9.2以降で動作します。</td></tr>
+<tr><td nowrap>NoSeqScan(テーブル)</td>
+  <td>指定したテーブルについて、Seq Scan以外でコストが最小となるスキャン方式を選択します。ただし、他のスキャン方式を選択できない場合は、Seq Scanを選択します。</td></tr>
+<tr><td nowrap>NoTidScan(テーブル)</td>
+  <td>指定したテーブルについて、Tid Scan以外でコストが最小となるスキャン方式を選択します。</td></tr>
+<tr><td nowrap>NoIndexScan(テーブル)</td>
+  <td>指定したテーブルについて、Index ScanとIndex Only Scanを除いたスキャン方式の中でコストが最小となるスキャン方式を選択します。</td></tr>
+<tr><td nowrap>NoIndexOnlyScan(テーブル)</td>
+  <td>指定したテーブルについて、Index Only Scan以外でコストが最小となるスキャン方式を選択します。PostgreSQL 9.2以降で動作します。</td></tr>
+<tr><td nowrap>NoBitmapScan(テーブル)</td>
+  <td>指定したテーブルについて、Bitmap Scan以外でコストが最小となるスキャン方式を選択します。</td></tr>
+
+<tr><td rowspan="6" nowrap>結合方式</td>
+  <td nowrap>NestLoop(テーブル テーブル[ テーブル...])</td>
+  <td>指定したテーブル間の結合にNested Loopを選択します。</td></tr>
+<tr><td nowrap>HashJoin(テーブル テーブル[ テーブル...])</td>
+  <td>指定したテーブル間の結合にHash Joinを選択します。</td></tr>
+<tr><td nowrap>MergeJoin(テーブル テーブル[ テーブル...])</td>
+  <td>指定したテーブル間の結合にMerge Joinを選択します。</td></tr>
+<tr><td nowrap>NoNestLoop(テーブル テーブル[ テーブル...])</td>
+  <td>指定したテーブル間の結合にNested Loop以外の結合方式を選択します。</td></tr>
+<tr><td nowrap>NoHashJoin(テーブル テーブル[ テーブル...])</td>
+  <td>指定したテーブル間の結合にHash Join以外の結合方式を選択します。</td></tr>
+<tr><td nowrap>NoMergeJoin(テーブル テーブル[ テーブル...])</td>
+  <td>指定したテーブル間の結合にMerge Join以外の結合方式を選択します。</td></tr>
+
+<tr><td rowspan="2">結合順序</td>
+  <td nowrap>Leading(テーブル テーブル[ テーブル...])</td>
+  <td>指定したテーブルを指定した順番通りに結合します。</td></tr>
+<tr><td nowrap>Leading((テーブル集合<Sup>注1</Sup> テーブル集合<Sup>注1</Sup>))</td>
+  <td>1つ目に指定したテーブル集合を外部表として、2つ目に指定したテーブル集合を内部表として結合します。書式中のテーブル集合はテーブルもしくは別のテーブル集合です。</td></tr>
+
+<tr><td>見積もり件数補正</td>
+  <td nowrap>Rows(テーブル テーブル[ テーブル...] 件数補正)</td>
+  <td>指定したテーブル間の結合結果の見積もり件数を補正します。件数補正として指定できるのは以下の4パターンです。
+      <p><dl>
+        <dt>#件数</dt><dd>指定した件数で本来の見積もり件を上書きします。</dd>
+        <dt>+件数</dt><dd>指定した件数を本来の見積もり件数に加算します。</dd>
+        <dt>-件数</dt><dd>指定した件数を本来の見積もり件数から減算します。</dd>
+        <dt>*倍率</dt><dd>本来の見積もり件数を指定した倍率に補正します。「*2」とすると見積もり件数が2倍になり、「*0.01」とすると見積もり件数が1/100になります。</dd>
+      </dl></p>
+なお、件数や倍率には、strtod()が解釈できる書式で数値を指定してください。
+</td></tr>
+
+<tr><td>パラレル実行の制御</td>
+  <td nowrap>Parallel(テーブル ワーカ数 [強制度])</td>
+  <td>パラレル実行を強制あるいは禁止します。ワーカ数が0の場合はパラレル実行を禁止します。強制度はワーカ数の適用方法を指定するもので "hard" または "soft" を指定します。デフォルト値である"soft"の場合は max_parallel_workers_per_gather のみを変更してあとはプランナに任せます。そして"hard" の場合は指定したワーカ数を強制します。</td>
+
+</td></tr>
+
+<tr><td>GUCパラメータ</td>
+  <td nowrap>Set(GUCパラメータ 値)</td>
+  <td>そのクエリの実行計画を作成している間だけ、指定したGUCパラメータを指定した値に変更します。</td></tr>
+</tbody>
+</table></p>
+<dt>
+<Sup>注1</Sup>テーブル集合とは、以下のような記述を指しています。</dt>
+<dd>テーブル集合 = {テーブル|(テーブル集合 テーブル集合)}</dd>
+
+
+<hr>
+<div class="navigation">
+  <a href="pg_hint_plan-ja.html">pg_hint_plan</a> &gt;
+  <a href="hint_list-ja.html">Appendix A. ヒント句一覧</a>
+</div>
+
+<p class="footer">Copyright (c) 2012-2020, NIPPON TELEGRAPH AND TELEPHONE CORPORATION</p>
+</body>
+</html>
diff --git a/gpcontrib/pg_hint_plan/doc/hint_list.html b/gpcontrib/pg_hint_plan/doc/hint_list.html
new file mode 100755
index 0000000000..a4d411e740
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/doc/hint_list.html
@@ -0,0 +1,95 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD html 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<title>Appendix A. Hints list</title>
+<!-- Uncoment after the tool has been hosted somewhere.
+<link rel="home" title="pg_hint_plan" href="index.html">
+-->
+<link rel="stylesheet" type="text/css" href="style.css">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+</head>
+
+<body>
+<h1 id="pg_hint_plan">pg_hint_plan 1.3 Appendices</h1>
+<div class="navigation">
+  <a href="pg_hint_plan.html">pg_hint_plan</a> &gt;
+  <a href="hint_list.html">Appendix A. Hints list</a>
+</div>
+<hr>
+
+<h2 id="hint-list">Appendix A. Hints list</h2>
+<p>The available hints are listed below.</p>
+<table>
+<thead>
+<tr>
+<tr><th>Group</th><th>Format</th><th>Description</th></tr>
+</tr>
+</thead>
+<tbody>
+<tr><td rowspan="11" nowrap>Scan method</td>
+  <td nowrap>SeqScan(table)</td>
+  <td>Forces sequential scan on the table</td></tr>
+<tr><td>TidScan(table)</td>
+  <td>Forces TID scan on the table.</td></tr>
+<tr><td nowrap>IndexScan(table[ index...])</td>
+  <td>Forces index scan on the table. Restricts to specified indexes if any. </td></tr>
+<tr><td nowrap>IndexOnlyScan(table[ index...])</td>
+  <td>Forces index only scan on the table. Rstricts to specfied indexes if any. Index scan may be used if index only scan is not available. Available for PostgreSQL 9.2 and later.</td></tr>
+<tr><td nowrap>BitmapScan(table[ index...])</td>
+  <td>Forces bitmap scan on the table. Restoricts to specfied indexes if any.</td></tr>
+<tr><td nowrap>IndexScanRegexp(table[ POSIX Regexp...])</br>IndexOnlyScanRegexp(table[ POSIX Regexp...])</br>BitmapScanRegexp(table[ POSIX Regexp...])</td>
+  <td>Forces index scan or index only scan (For PostgreSQL 9.2 and later) or bitmap scan on the table. Restricts to indexes that matches the specified <a href="https://www.postgresql.org/docs/11/functions-matching.html#FUNCTIONS-POSIX-REGEXP">POSIX regular expression</a> pattern</td></tr>
+<tr><td nowrap>NoSeqScan(table)</td>
+  <td>Forces not to do sequential scan on the table.</td></tr>
+<tr><td nowrap>NoTidScan(table)</td>
+  <td>Forces not to do TID scan on the table. </td></tr>
+<tr><td nowrap>NoIndexScan(table)</td>
+  <td>Forces not to do index scan and index only scan (For PostgreSQL
+  9.2 and later) on the table. </td></tr>
+<tr><td nowrap>NoIndexOnlyScan(table)</td>
+  <td>Forces not to do index only scan on the table. Available for PostgreSQL 9.2 and later.</td></tr>
+<tr><td nowrap>NoBitmapScan(table)</td>
+  <td>Forces not to do bitmap scan on the table. </td></tr>
+
+<tr><td rowspan="6" nowrap>Join method</td>
+  <td nowrap>NestLoop(table table[ table...])</td>
+  <td>Forces nested loop for the joins consist of the specifiled tables.</td></tr>
+<tr><td nowrap>HashJoin(table table[ table...])</td>
+  <td>Forces hash join for the joins consist of the  specifiled tables.</td></tr>
+<tr><td nowrap>MergeJoin(table table[ table...])</td>
+  <td>Forces merge join for the joins consist of the specifiled tables.</td></tr>
+<tr><td nowrap>NoNestLoop(table table[ table...])</td>
+  <td>Forces not to do nested loop for the joins consist of the specifiled tables.</td></tr>
+<tr><td nowrap>NoHashJoin(table table[ table...])</td>
+  <td>Forces not to do hash join for the joins consist of the specifiled tables.</td></tr>
+<tr><td nowrap>NoMergeJoin(table table[ table...])</td>
+  <td>Forces not to do merge join for the joins consist of the  specifiled tables.</td></tr>
+
+<tr><td rowspan="2">Join order</td>
+  <td nowrap>Leading(table table[ table...])</td>
+  <td>Forces join order as specified.</td></tr>
+<tr><td nowrap>Leading(&lt;join pair&gt;)</td>
+	<td>Forces join order and directions as specified. A join pair is a pair of tables and/or other join pairs enclosed by parentheses, which can make a nested structure.</td>
+
+<tr><td>Row number correction</td>
+	<td nowrap>Rows(table table[ table...] correction)</td>
+  <td>Corrects row number of a result of the joins consist of the specfied tables. The available correction methods are absolute (#&ltn&gt), addition (+&ltn&gt), subtract (-&ltn&gt) and multiplication (*&ltn&gt). &ltn&gt should be a string that strtod() can read.</td></tr>
+<tr><td>Parallel query configuration</td>
+	<td nowrap>Parallel(table &lt# of workers&gt [soft|hard])</td>
+  <td>Enforce or inhibit parallel execution of specfied table. &lt# of workers&gt is the desired number of parallel workers, where zero means inhibiting parallel execution. If the third parameter is soft (default), it just changes max_parallel_workers_per_gather and leave everything else to planner. Hard means enforcing the specified number of workers.</td>
+<tr><td>GUC</td>
+  <td nowrap>Set(GUC-param value)</td>
+  <td>Set the GUC parameter to the value while planner is running.</td></tr>
+</tbody>
+</table></p>
+
+
+<hr>
+<div class="navigation">
+  <a href="pg_hint_plan.html">pg_hint_plan</a> &gt;
+  <a href="hint_list.html">Appendix A. hints list</a>
+</div>
+
+<p class="footer">Copyright (c) 2012-2020, NIPPON TELEGRAPH AND TELEPHONE CORPORATION</p>
+</body>
+</html>
diff --git a/gpcontrib/pg_hint_plan/doc/pg_hint_plan-ja.html b/gpcontrib/pg_hint_plan/doc/pg_hint_plan-ja.html
new file mode 100755
index 0000000000..5989ab39ad
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/doc/pg_hint_plan-ja.html
@@ -0,0 +1,700 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD html 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="ja">
+<head>
+<title>pg_hint_plan</title>
+<!-- Uncoment after the tool has been hosted somewhere.
+<link rel="home" title="pg_hint_plan" href="index.html">
+-->
+<link rel="stylesheet" type="text/css" href="style.css">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+</head>
+
+<body>
+<h1 id="pg_hint_plan">pg_hint_plan 1.3</h1>
+<div class="navigation">
+  <a href="pg_hint_plan-ja.html">pg_hint_plan</a>
+</div>
+<hr>
+
+<div class="index">
+<ol>
+<li><a href="#name">名前</a></li>
+<li><a href="#synopsis">概要</a></li>
+<li><a href="#description">機能説明</a>
+<li><a href="#install">インストール</a></li>
+<li><a href="#uninstall">アンインストール</a></li>
+<li><a href="#restrictions">使用上の注意と制約</a></li>
+<li><a href="#requirement">動作環境</a></li>
+<li><a href="#seealso">関連項目</a></li>
+<li><a href="hint_list-ja.html">Appendix A. ヒント句一覧</a></li>
+</div>
+
+<h2 id="name">名前</h2>
+<p>pg_hint_plan -- 実行計画を示すヒントをクエリに指定することで、SQL文やGUCパラメータを変えずに実行計画を制御します。</p>
+
+<h2 id="synopsis">概要</h2>
+<p>PostgreSQLのプランナははコストベースでのオプティマイズを行なっており、SQL文と統計情報を元に可能な実行計画のコストを見積もり、最もコストの低い実行計画を選択します。プランナは可能な限りよい実行計画を作成しようとしますが、例えばカラム間の相関関係などは考慮しないため、複雑なクエリでは常に最適なプランを選択するとは限りません。</p>
+<p>pg_hint_planを用いると、ヒントでスキャン方式や結合方式を指定することで、SQL文やGUCパラメータを変更することなく実行計画を制御することができます。</p>
+
+<h2 id="description">機能説明</h2>
+<p>pg_hint_planの機能について説明するにあたり、まず文中で使用されている用語について説明します。</p>
+<table>
+<thead>
+<tr>
+<tr><th>用語</th><th>説明</th></tr>
+</tr></thead>
+<tbody>
+<tr><td>ヒント句</td>
+  <td>実行計画を制御するための情報です。</td></tr>
+  <tr><td>ヒント</td>
+  <td>実行計画を制御したいクエリに適用するヒント句を列挙したものです。</td></tr>
+</tbody>
+</table>
+
+<h3 id="hint-rule">ヒントの指定方法</h3>
+<p>ヒントは二つの方法で指定することができます。</p>
+<ul>
+<li>コメントでの指定</li>
+<p>特殊なSQLブロックコメント内にヒントを記述します。</p>
+<li>テーブルでの指定</li>
+<p>ヒント用のテーブルにヒントを登録します。</p>
+</ul>
+<p>特定のアプリケーションではヒントをコメントで指定することができないため、「テーブルでの指定」でヒントを指定します。なお、「コメントでの指定」と異なり、アプリケーションのソースコードに手を入れずに指定するヒントを変更することができます。</p>
+
+<h4 id="hint-comment">コメントでの指定</h4>
+<p>指定したいヒントを、実行計画を制御したいクエリの先頭または途中のSQLブロックコメントの中に記述します。</p>
+<p>ヒント用コメントと通常のコメントを区別するために、ヒント用のブロックコメントは「<span class="bold">/*+</span>」で始めます。ヒントの対象は、カッコ内にオブジェクト名または別名で指定します。オブジェクト名は、スペース、タブ、または改行のいずれかで区切って指定します。</p>
+<p>以下の例では、HashJoinとSeqScanヒント句により、pgbench_accountsテーブルに対するSeq Scanの結果をHash Joinする実行計画が選択されています。なおかつ、Setヒント句によりこのクエリの実行計画を作成する間だけrandom_page_costが2.0に変更されています。</p>
+<pre>
+<span class="strong">postgres=#</span> EXPLAIN (VERBOSE, COSTS)
+<span class="strong">postgres-# /*+</span>
+<span class="strong">postgres*#     SeqScan(a)</span>
+<span class="strong">postgres*#     HashJoin(a b)</span>
+<span class="strong">postgres*#     Set(random_page_cost 2.0)</span>
+<span class="strong">postgres*#  */</span>
+<span class="strong">postgres-#</span> SELECT *
+<span class="strong">postgres-#</span>   FROM pgbench_accounts a
+<span class="strong">postgres-#</span>   JOIN pgbench_branches b
+<span class="strong">postgres-#</span>     ON a.bid = b.bid
+<span class="strong">postgres-#</span>  ORDER BY a.aid
+<span class="strong">postgres-#</span>  LIMIT 10;
+                                             QUERY PLAN
+----------------------------------------------------------------------------------------------------
+ Limit  (cost=6176.99..6177.01 rows=10 width=461)
+   Output: a.aid, a.bid, a.abalance, a.filler, b.bid, b.bbalance, b.filler, a.aid
+   ->  Sort  (cost=6176.99..6426.99 rows=100000 width=461)
+         Output: a.aid, a.bid, a.abalance, a.filler, b.bid, b.bbalance, b.filler, a.aid
+         Sort Key: a.aid
+         ->  <span class="strong">Hash Join</span>  (cost=1.02..4016.02 rows=100000 width=461)
+               Output: a.aid, a.bid, a.abalance, a.filler, b.bid, b.bbalance, b.filler, a.aid
+               Hash Cond: (a.bid = b.bid)
+               ->  <span class="strong">Seq Scan on public.pgbench_accounts a</span>  (cost=0.00..2640.00 rows=100000 width=97)
+                     Output: a.aid, a.bid, a.abalance, a.filler
+               ->  Hash  (cost=1.01..1.01 rows=1 width=364)
+                     Output: b.bid, b.bbalance, b.filler
+                     ->  Seq Scan on public.pgbench_branches b  (cost=0.00..1.01 rows=1 width=364)
+                           Output: b.bid, b.bbalance, b.filler
+(14 rows)
+
+postgres=# 
+</pre>
+
+<h4 id="hint-table">テーブルでの指定</h4>
+<p>指定したいヒントを、実行計画を制御したいクエリと併せてヒント用のテーブルに登録します。</p>
+<p>デフォルトでは無効なので、テーブルで指定したヒントは適用されません。そのため、ヒントをテーブルで指定する場合は、<a href="#hint-GUC">pg_hint_planのGUCパラメータ</a>pg_hint_plan.enable_hint_tableの設定を変更します。</p>
+<p>ヒント用のテーブルは「<span class="bold">hint_plan.hints</span>」です。hint_plan.hintsテーブルには、以下の情報を登録します。</p>
+<table>
+<thead>
+<tr>
+<tr><th>列名</th><th>説明</th></tr>
+</tr></thead>
+<tbody>
+<tr><td>id</td>
+  <td>ユーザがヒントを識別するための番号です。連番型ですので、新しいヒントを登録するときにはこの列を指定しないでください。</td></tr>
+<tr><td>norm_query_string</td>
+  <td>実行計画を制御したいクエリを指定します。対象のクエリに定数があるときは、下記の例のように「?」に置き換えます。キーワード間の空白の数が、登録するクエリと実行するクエリで異なると別のSQL文として扱われます。</td></tr>
+<tr><td>application_name</td>
+  <td>ヒント適用対象のアプリケーション名を指定します。下記の例では「psql」から実行されたクエリのみがヒント適用対象となります。全てのアプリケーションにヒントを適用したいときは、空文字列を登録します。アプリケーション名は、セッションの「application_name」GUCパラメータと等しいか判断します。</td></tr>
+<tr><td>hints</td>
+  <td>ヒントを指定します。SQLコメント記号を除いた内容のみを登録します。</td></tr>
+</tbody>
+</table>
+<p>ヒントの登録情報を変更する場合は、変更したい登録情報のidを指定して登録情報を更新してください。</br>
+ヒントの登録を解除する場合は、解除したい登録情報のidを指定してテーブルから削除してください。</p>
+<p>以下の例では、ヒントの登録、ヒント登録情報の変更、ヒントの解除の順に、クエリの実行結果を示しています。
+</p>
+<pre>
+<span class="strong">postgres=#</span> INSERT INTO hint_plan.hints(norm_query_string, application_name, hints)
+<span class="strong">postgres-#</span>     VALUES (
+<span class="strong">postgres(#</span>         'EXPLAIN (COSTS false) SELECT * FROM t1 WHERE t1.id = ?;',
+<span class="strong">postgres(#</span>         '',
+<span class="strong">postgres(#</span>         'SeqScan(t1)'
+<span class="strong">postgres(#</span>     );
+INSERT 0 1
+<span class="strong">postgres=#</span> UPDATE hint_plan.hints
+<span class="strong">postgres-#</span>    SET hints = 'IndexScan(t1)'
+<span class="strong">postgres-#</span>  WHERE id = 1;
+UPDATE 1
+<span class="strong">postgres=#</span> DELETE FROM hint_plan.hints
+<span class="strong">postgres-#</span>  WHERE id = 1;
+DELETE 1
+<span class="strong">postgres=#</span>
+</pre>
+<p>なお、ヒントの登録や変更や解除はスーパーユーザでのみ可能です。一般ユーザでヒントの登録や変更や解除を実施したい場合は、スーパーユーザから一般ユーザにhint_plan.hintsテーブルの各権限を付与してください。</p>
+<p>以下の例では、hint_plan.hintsテーブルに対してINSERT権限を持たない一般ユーザがヒントの登録を実施しようとしたときの結果を示しています。</p>
+<pre>
+<span class="strong">postgres=></span> INSERT INTO hint_plan.hints(norm_query_string, application_name, hints)
+<span class="strong">postgres-></span>     VALUES (
+<span class="strong">postgres(></span>         'EXPLAIN (COSTS false) SELECT * FROM t1 WHERE t1.id = ?;',
+<span class="strong">postgres(></span>         '',
+<span class="strong">postgres(></span>         'SeqScan(t1)'
+<span class="strong">postgres(></span>     );
+ERROR:  permission denied for relation hints
+<span class="strong">postgres=></span>
+</pre>
+<p>以下の例では、テーブルに登録した「コメントでの指定」の例と同じヒントと、登録したクエリの実行結果を示しています。</p>
+<pre>
+<span class="strong">postgres=#</span> SELECT * FROM hint_plan.hints;
+ id |     norm_query_string      | application_name |                      hints
+----+----------------------------+------------------+--------------------------------------------------
+  1 | EXPLAIN (VERBOSE, COSTS)  +| psql             | SeqScan(a)HashJoin(a b)Set(random_page_cost 2.0)
+    |  SELECT *                 +|                  |
+    |    FROM pgbench_accounts a+|                  |
+    |    JOIN pgbench_branches b+|                  |
+    |      ON a.bid = b.bid     +|                  |
+    |   ORDER BY a.aid          +|                  |
+    |   LIMIT ?;                +|                  |
+    |                            |                  |
+...
+
+<span class="strong">postgres=#</span> SET pg_hint_plan.enable_hint_table TO on;
+<span class="strong">postgres=#</span> EXPLAIN (VERBOSE, COSTS)
+<span class="strong">postgres-#</span> SELECT *
+<span class="strong">postgres-#</span>   FROM pgbench_accounts a
+<span class="strong">postgres-#</span>   JOIN pgbench_branches b
+<span class="strong">postgres-#</span>     ON a.bid = b.bid
+<span class="strong">postgres-#</span>  ORDER BY a.aid
+<span class="strong">postgres-#</span>  LIMIT 10;
+                                             QUERY PLAN
+----------------------------------------------------------------------------------------------------
+ Limit  (cost=6176.99..6177.01 rows=10 width=461)
+   Output: a.aid, a.bid, a.abalance, a.filler, b.bid, b.bbalance, b.filler, a.aid
+   ->  Sort  (cost=6176.99..6426.99 rows=100000 width=461)
+         Output: a.aid, a.bid, a.abalance, a.filler, b.bid, b.bbalance, b.filler, a.aid
+         Sort Key: a.aid
+         ->  <span class="strong">Hash Join</span>  (cost=1.02..4016.02 rows=100000 width=461)
+               Output: a.aid, a.bid, a.abalance, a.filler, b.bid, b.bbalance, b.filler, a.aid
+               Hash Cond: (a.bid = b.bid)
+               ->  <span class="strong">Seq Scan on public.pgbench_accounts a</span>  (cost=0.00..2640.00 rows=100000 width=97)
+                     Output: a.aid, a.bid, a.abalance, a.filler
+               ->  Hash  (cost=1.01..1.01 rows=1 width=364)
+                     Output: b.bid, b.bbalance, b.filler
+                     ->  Seq Scan on public.pgbench_branches b  (cost=0.00..1.01 rows=1 width=364)
+                           Output: b.bid, b.bbalance, b.filler
+(14 rows)
+
+postgres=# 
+</pre>
+
+<div class="tips">
+<span class="strong">指定方法の優先度</span>
+<p>ヒントをコメントとテーブルの両方で指定した場合、テーブルで指定したヒントが適用され、コメントで指定したヒントは無視されます。</p>
+<p>以下の例では、コメントでヒントを指定して実行計画を制御しているクエリに対して、テーブルに空文字列のヒントを登録しています。テーブルで指定したヒントが優先されるので、コメントで指定したヒントを取り消すことができます。</p>
+<pre>
+postgres=# select * from hint_plan.hints;
+ id |             norm_query_string              | application_name | hints
+----+--------------------------------------------+------------------+-------
+  1 | EXPLAIN (VERBOSE, COSTS)                  +| psql             |
+    | /*+                                       +|                  |
+    |     HashJoin(a b)                         +|                  |
+    |     SeqScan(a)                            +|                  |
+    |  */                                       +|                  |
+    | SELECT *                                  +|                  |
+    |   FROM pgbench_accounts a                 +|                  |
+    |   JOIN pgbench_branches b ON a.bid = b.bid+|                  |
+    |  ORDER BY a.aid;                           |                  |
+...
+
+postgres=# EXPLAIN (VERBOSE, COSTS)
+postgres-# /*+
+postgres*#     HashJoin(a b)
+postgres*#     SeqScan(a)
+postgres*#  */
+postgres-# SELECT *
+postgres-#   FROM pgbench_accounts a
+postgres-#   JOIN pgbench_branches b ON a.bid = b.bid
+postgres-#  ORDER BY a.aid;
+                                                      QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------
+ <span class="strong">Nested Loop</span>  (cost=0.00..5750.47 rows=100000 width=461)
+   Output: a.aid, a.bid, a.abalance, a.filler, b.bid, b.bbalance, b.filler, a.aid
+   Join Filter: (a.bid = b.bid)
+   ->  <span class="strong">Index Scan using pgbench_accounts_pkey on public.pgbench_accounts a</span>  (cost=0.00..4249.45 rows=100000 width=97)
+         Output: a.aid, a.bid, a.abalance, a.filler
+   ->  Materialize  (cost=0.00..1.01 rows=1 width=364)
+         Output: b.bid, b.bbalance, b.filler
+         ->  Seq Scan on public.pgbench_branches b  (cost=0.00..1.01 rows=1 width=364)
+               Output: b.bid, b.bbalance, b.filler
+(9 rows)
+</pre>
+</div>
+
+<h3 id="hint-group">ヒント句のグループ</h3>
+<p>pg_hint_planで使えるヒント句の種類は、スキャン方式と結合方式、結合順序、見積もり件数補正、並列実行の設定、GUCパラメータの6グループです。各グループの具体的なヒント句は、<a href="hint_list-ja.html">ヒント句一覧</a>を参照してください。</p>
+
+<h4>スキャン方式</h4>
+<p>あるオブジェクトでどのスキャン方式を選択するかを指定できるヒント句のグループです。「SeqScan」や「IndexScan」などを含みます。</p>
+<p>スキャン方式を指定できるオブジェクトは、通常のテーブル、継承テーブル、UNLOGGEDテーブル、一時テーブル、システムカタログです。スキャン方式を指定できないオブジェクトは、外部テーブル、テーブル関数、VALUESコマンド結果、CTE(共通テーブル式)、ビュー、副問い合わせ結果です。</p>
+<p>特定のオブジェクトについてあるスキャン方式を選択して欲しい場合は、そのスキャン方式のヒント句と、対象となるオブジェクトの名前を指定します。逆に、特定のオブジェクトについてあるスキャン方式を選択して欲しくない場合は、Noで始まるヒント句を指定します。同じオブジェクトに対して複数のスキャン方式のヒント句を指定した場合は、最後に指定したヒント句が適用されます。</p>
+
+<h4>結合方式</h4>
+<p>あるオブジェクトの組み合わせでどの結合方式を選択するかを指定できるヒント句のグループです。「MergeJoin」や「NestLoop」などを含みます。</p>
+<p>結合方式を指定できるオブジェクトは、通常のテーブル、継承テーブル、UNLOGGEDテーブル、一時テーブル、外部テーブル、システムカタログ、テーブル関数、VALUESコマンド結果、CTE(共通テーブル式)です。結合方式を指定できないオブジェクトは、ビュー、副問い合わせ結果です。</p>
+<p>特定のオブジェクトの組み合わせについてある結合方式を選択して欲しい場合は、その結合方式のヒント句と、対象となる2つ以上のオブジェクトの名前を指定します。逆に、特定のオブジェクトの組み合わせについてある結合方式を選択して欲しくない場合は、Noで始まるヒント句を指定します。同じオブジェクトの組み合わせに対して複数の結合方式のヒント句を指定した場合は、最後に指定したヒント句が適用されます。</p>
+
+<h4>結合順序</h4>
+<p>あるオブジェクトの組み合わせでどのような順番で結合するかを指定できるヒント句のグループです。「Leading」のみを含みます。</p>
+<p>結合順序を指定できるオブジェクトは結合方式と同じです。</p>
+<p>先に結合して欲しいオブジェクトから順にオブジェクト名または別名を指定します。同じ問合せブロックのオブジェクトに対して複数の結合順序のヒント句を指定した場合は、最後に指定したヒント句が適用されます。 </p>
+<div class="tips">
+<p>結合対象のテーブルが3つ以上ある場合、結合方式のヒント句を指定したとしてもコスト見積もりによっては対象のテーブルが直接結合されないことがあります。対象のテーブルが直接結合されない場合は、結合順序のヒント句を併せて指定します。</p>
+<p>以下の例では、table1とtable2を直接結合する場合はNested Loopを、table1とtable2とtable3を結合する場合はMerge Joinを指定しています。また、コスト見積もりによってはtable1とtable2が直接結合されない場合を避けるため、table1とtable2を結合してからtable3を結合するようにLeadingヒント句を併用しています。</p>
+<pre>
+<span class="strong">postgres=# /*+</span>
+<span class="strong">postgres*#     NestLoop(t1 t2)</span>
+<span class="strong">postgres*#     MergeJoin(t1 t2 t3)</span>
+<span class="strong">postgres*#     Leading(t1 t2 t3)</span>
+<span class="strong">postgres*#  */</span>
+<span class="strong">postgres-#</span> SELECT * FROM table1 t1
+<span class="strong">postgres-#</span>     JOIN table table2 t2 ON (t1.key = t2.key)
+<span class="strong">postgres-#</span>     JOIN table table3 t3 ON (t2.key = t3.key);
+...
+</pre>
+</div>
+<h4>結合方向</h4>
+<p>上記の結合順序の指定を行なった際にはプランナの都合により結合方向(外部表/内部表もしくは駆動表/被駆動表の別)が期待とは異なるものになる場合があります。このような状況に対して結合方向を固定したい場合はもうひとつの書式を使う必要があります。</p>
+<pre>
+<span class="strong">postgres=# /*+ Leading((t1 (t2 t3))) */</span> SELECT...
+</pre>
+<p>この書式では2つの要素を丸括弧で囲ったものがネストする形になっており、一つの括弧内では1つ目の要素が外部/駆動表、2番めの要素が内部/被駆動表として結合されます。</p>
+<h4>見積もり件数補正</h4>
+<p>あるオブジェクトの結合結果の件数を補正できるヒント句のグループです。「Rows」のみを含みます。</p>
+<p>見積もり件数補正対象として指定できるオブジェクトは結合方式と同じです。補正できるのは結合結果の見積もり件数だけで、スキャンの見積もり件数を補正することはできません。</p>
+<p>以下の例では、テーブルaとテーブルbの結合結果の件数を、ヒント句で指定した値に補正しています。</p>
+<pre>
+<span class="strong">postgres=# /*+ Rows(a b #10) */</span>
+<span class="strong">postgres-#</span> EXPLAIN SELECT *
+<span class="strong">postgres-#</span>    FROM pgbench_branches b
+<span class="strong">postgres-#</span>    JOIN pgbench_accounts a ON b.bid = a.bid
+<span class="strong">postgres-#</span>   WHERE aid &lt; 20
+<span class="strong">postgres-#</span>   ORDER BY a.aid;
+                                               QUERY PLAN
+--------------------------------------------------------------------------------------------------------
+ Nested Loop  (cost=0.29..9.92 rows=<span class="strong">10</span> width=461)
+   Join Filter: (b.bid = a.bid)
+   ->  Index Scan using pgbench_accounts_pkey on pgbench_accounts a  (cost=0.29. .8.62 rows=19 width=97)
+         Index Cond: (aid &lt; 20)
+   ->  Materialize  (cost=0.00..1.01 rows=1 width=364)
+         ->  Seq Scan on pgbench_branches b  (cost=0.00..1.01 rows=1 width=364)
+(6 行)
+</pre>
+
+<h4>並列実行の指定</h4>
+<p>スキャンの並列実行の方法を指定します。最初のパラメータは対象とするオブジェクトの指定で、2番目に指定する数だけ並列処理ワーカを起動するように指定します。
+<p>3番目のパラメータは強制の程度を指定します。 "soft" は max_parallel_workers_per_gather のみを変更して適用はプランナに任せます。"hard" は他のプランナ変数も変更するなどしてワーカ数を強制します。</p>
+<p>以下の例では、テーブル c1 とテーブル c2 の結合で各々異なるワーカ数を強制します。</p>
+<pre>
+<span class="strong">postgres=#</span> explain <span class="strong">/*+ Parallel(c1 3 hard) Parallel(c2 5 hard) */</span>
+                  select c2.a from c1 join c2 on (c1.a = c2.a);
+                                  QUERY PLAN                                   
+-------------------------------------------------------------------------------
+ Hash Join  (cost=2.86..11406.38 rows=101 width=4)
+   Hash Cond: (c1.a = c2.a)
+   ->  Gather  (cost=0.00..7652.13 rows=1000101 width=4)
+         <span class="strong">Workers Planned: 3</span>
+         ->  Parallel Seq Scan on <span class="strong">c1</span>  (cost=0.00..7652.13 rows=322613 width=4)
+   ->  Hash  (cost=1.59..1.59 rows=101 width=4)
+         ->  Gather  (cost=0.00..1.59 rows=101 width=4)
+               <span class="strong">Workers Planned: 5</span>
+               ->  Parallel Seq Scan on <span class="strong">c2</span>  (cost=0.00..1.59 rows=59 width=4)
+</pre>
+
+<h4>GUCパラメータ</h4>
+<p>そのクエリの実行計画を作成している間だけGUCパラメータを変更できるヒント句のグループです。「Set」のみを含みます。</p>
+<p>設定したいGUCパラメータとそのパラメータの値を指定します。指定できるGUCパラメータは<a href="http://www.postgresql.jp/document/current/html/runtime-config-query.html">問い合わせ計画</a>のGUCパラメータのみです。同じGUCパラメータのヒント句を2回以上指定した場合は、最後に指定したヒント句が適用されます。</p>
+<div class="tips">
+<span class="strong">Setヒント句の制限</span>
+<p>Setヒント句に問い合わせ計画のGUCパラメータ以外を指定した場合の動作は保証できません。問い合わせ計画以外のGUCパラメータを指定した場合の例の一つとして、<a href="#hint-GUC">pg_hint_planのGUCパラメータ</a>を指定した場合の動作を、以下に示します。<p>
+<ul>
+<li>pg_hint_plan.enable_hint、pg_hint_plan.enable_hint_tableをSetヒント句の対象に指定した場合は、無効になります。なお、pg_hint_plan.debug_printをonに設定していると、そのヒント句はログ出力で「適用されたヒント句」として出力されます。</li>
+<li>pg_hint_plan.debug_printをSetヒント句の対象に指定した場合は、指定したとおりに適用されます。</li>
+<li>pg_hint_plan.parse_messagesをSetヒント句の対象に指定した場合は、構文エラーと一部のSetヒント句のエラーのメッセージはクエリ開始時の設定レベルで出力され、それ以外のメッセージはSetヒント句で指定したレベルで出力されます。</li>
+</ul>
+</div>
+
+<h3 id="hint-GUC">pg_hint_planのGUCパラメータ</h3>
+<p>pg_hint_planの動作を制御するGUCパラメータを以下に記述します。</p>
+<table>
+<thead>
+<tr>
+<tr><th>GUCパラメータ</th><th>説明</th><th>デフォルト値</th></tr>
+</tr></thead>
+<tbody>
+<tr><td>pg_hint_plan.enable_hint</td>
+  <td>pg_hint_planの機能を有効または無効にします。</td><td>on</td></tr>
+<tr><td>pg_hint_plan.enable_hint_table</td>
+  <td>ヒントをテーブルで指定する機能を有効または無効にします。</td><td>off</td></tr>
+<tr><td>pg_hint_plan.parse_messages</td>
+  <td>指定したヒントを解釈できなかった場合のログメッセージのレベルを指定します。有効な値は、debug5、debug4、debug3、debug2、debug1、log、info、notice、warning、またはerrorです。</td><td>INFO</td></tr>
+<tr><td>pg_hint_plan.debug_print</td>
+  <td>動作状況を示すログメッセージの出力を制御します。指定可能な値は off, on, verbose, detailed です。</td><td>off</td></tr>
+<tr><td>pg_hint_plan.message_level</td>
+  <td>動作ログメッセージのログレベルを指定します。有効な値は、debug5、debug4、debug3、debug2、debug1、log、info、notice、warning、またはerrorです。</td><td>LOG</td></tr>
+
+</tbody>
+</table>
+<h2 id="install">インストール</h2>
+<p>pg_hint_planのインストール方法について説明します。</p>
+
+<h3 id="build">ビルド</h3>
+<p>pg_hint_planをソースコードからビルドする場合、pg_hint_planのソースを展開したディレクトリでmake → make installの順に実行します。make installはPostgreSQLをインストールしたOSユーザで実行します。なお、pg_hint_planのビルドにはpgxsを使用するので、RPM版のPostgreSQLを使用している環境では、postgresql-devel パッケージが必要です。</p>
+<p>以下にビルドの例を示します。</p>
+<pre>
+$ tar xzvf pg_hint_plan-1.0.0.tar.gz
+$ cd pg_hint_plan-1.0.0
+$ make
+$ su
+# make install
+</pre>
+
+<h3 id="create-extension">データベースへの登録</h3>
+<p>pg_hint_planはPostgreSQLの拡張(EXTENSION)を使用しているので、pg_hint_planを利用するデータベースにスーパーユーザもしくはそのデータベースの所有者で接続してCREATE EXTENSIONコマンドを実行します。</p>
+<p>以下にデータベースへの登録の例を示します。 <i>dbname</i>は対象となるデータベース名を意味します。</p>
+<pre>
+$ psql -d <i>dbname</i> -c "CREATE EXTENSION pg_hint_plan"
+</pre>
+
+<h3 id="hint-load">pg_hint_planのロード</h3>
+<p>特定のセッションでのみpg_hint_planを使う場合は、以下の例のようにpg_hint_planの共有ライブラリをLOADコマンドでロードします。一般ユーザで利用する場合は$libdir/pluginsにもインストールする必要があるので注意してください。
+<pre>
+postgres=# LOAD 'pg_hint_plan';
+LOAD
+postgres=# </pre></p>
+<p>全てのセッションでpg_hint_planを有効にするには、shared_preload_libraries GUCパラメータに'pg_hint_plan'を追加してからサーバを再起動します。</p>
+<p>注意: pg_hint_planを<a href="#create-extension">データベースに登録</a>せずに、ロード後にSQL文を実行すると以下に示す例のようなエラーとなります。 pg_hint_planを使うときは、データベースへの登録を忘れないように注意してください。</p>
+<pre>
+postgres=# EXPLAIN SELECT * FROM pgbench_accounts a WHERE aid = 1;
+ERROR:  schema "hint_plan" does not exist
+LINE 1: SELECT hints   FROM hint_plan.hints  WHERE norm_query_string...
+                            ^
+QUERY:  SELECT hints   FROM hint_plan.hints  WHERE norm_query_string = $1    AND ( application_name = $2     OR application_name = '' )  ORDER BY application_name DESC
+postgres=#
+</pre>
+
+<h2 id="uninstall">アンインストール</h2>
+<p>pg_hint_planをアンインストールするときは、以下の手順を実行します。 <i>dbname</i>は対象となるデータベース名を意味します。</p>
+<ol>
+<li>pg_hint_planのソースを展開したディレクトリでmake uninstallを実行します。make uninstallはPostgreSQLをインストールしたOSユーザで実行します。</li>
+<pre>
+$ cd pg_hint_plan-1.0.0
+$ su
+# make uninstall
+</pre>
+<li>pg_hint_planを登録したデータベースにスーパーユーザもしくはそのデータベースの所有者で接続して、DROP EXTENSIONコマンドおよびDROP SCHEMAコマンドを実行します。</li>
+<pre>
+$ psql -d <i>dbname</i> -c "DROP EXTENSION pg_hint_plan"
+$ psql -d <i>dbname</i> -c "DROP SCHEMA hint_plan"
+</pre>
+</ol>
+
+<h2 id="restrictions">ヒントの指定に関する詳細</h2>
+<p>以下にいくつかのトピックに関してヒントの動作について説明します。</p>
+<dl>
+<dt>コメント指定でのヒント記述位置と文法</dt>
+<dd>ヒントはクエリの先頭または途中に記述できます。ただし、ヒントをクエリの途中に記述する場合、ヒント用のブロックコメントより前に以下の文字<span class="strong">以外</span>が含まれると、「/*+」で始まるコメントでもヒントと見なされず無視されます。
+<ul>
+<li>空白文字(半角スペース、水平/垂直タブ、改行、フォームフィード、復帰)</li>
+<li>アルファベット(大文字/小文字)</li>
+<li>数字</li>
+<li>アンダースコア</li>
+<li>カンマ</li>
+<li>開き括弧(()、閉じ括弧())</li>
+</ul>
+<p>指定したヒントが無視される例を以下に示します。</p>
+<ol>
+<li>二重引用符(")がヒント用のブロックコメントより前に含まれている場合</li>
+<pre>
+postgres=# SELECT bid AS "BID" 
+postgres-# /*+
+postgres*#     SeqScan(b)
+postgres*#  */
+postgres-#   FROM pgbench_branches b;
+...
+</pre>
+<li>演算子(>=)がヒント用のブロックコメントより前に含まれている場合</li>
+<pre>
+postgres=# WITH avg_aid AS (
+postgres(#    SELECT avg(aid) FROM pgbench_history h
+postgres(#     WHERE delta >= 0
+postgres(# )
+postgres-# /*+
+postgres*#     SeqScan(h)
+postgres*#  */
+postgres-# SELECT * FROM avg_aid;
+...
+</pre>
+</ol>
+一つのクエリに複数のブロックコメントを記述する場合は、最初のブロックコメントにのみヒントを記述してください。二番目以降のブロックコメントは、ヒントと見なされず無視されます。以下の例では、HashJoin(a b)とSeqScan(a)がヒントと見なされ、IndexScan(a)とMergeJoin(a b)は無視されています。</p>
+<pre>
+postgres=# /*+
+postgres*#     <span class="strong">HashJoin(a b)</span>
+postgres*#     <span class="strong">SeqScan(a)</span>
+postgres*#  */
+postgres-# /*+ IndexScan(a) */
+postgres-# EXPLAIN SELECT /*+ MergeJoin(a b) */ *
+postgres-#    FROM pgbench_branches b
+postgres-#    JOIN pgbench_accounts a ON b.bid = a.bid
+postgres-#   ORDER BY a.aid;
+                                      QUERY PLAN
+---------------------------------------------------------------------------------------
+ Sort  (cost=31465.84..31715.84 rows=100000 width=197)
+   Sort Key: a.aid
+   ->  <span class="strong">Hash Join</span>  (cost=1.02..4016.02 rows=100000 width=197)
+         Hash Cond: (a.bid = b.bid)
+         ->  <span class="strong">Seq Scan on pgbench_accounts a</span>  (cost=0.00..2640.00 rows=100000 width=97)
+         ->  Hash  (cost=1.01..1.01 rows=1 width=100)
+               ->  Seq Scan on pgbench_branches b  (cost=0.00..1.01 rows=1 width=100)
+(7 rows)
+
+postgres=# </pre>
+</dd>
+<dt>PL/pgSQL中の個別のクエリに対するヒント</dt>
+<dd>ヒントは、PL/pgSQLブロック中の各クエリにも指定できます。ただし、以下のような制約があります。
+<ul>
+<li>指定したヒントが適用されるSQLは以下の通りです。他のSQLにヒントを指定しても適用されません。
+<ul>
+<li>1行の結果を返す問い合わせ文(SELECT/INSERT/UPDATE/DELETE)</li>
+<li>複数行の結果を返す問い合わせ文(RETURN QUERY)</li>
+<li>動的SQL文(EXECUTE)</li>
+<li>カーソルを開く文(OPEN)</li>
+<li>問い合わせの結果を用いる繰り返し文(FOR)</li>
+</ul>
+</li>
+<li>ヒントをコメントで指定する場合は、SELECTなどのSQLキーワードより後に指定してください。ただし、動的SQL文にヒントをコメントで指定しても、そのヒントは適用されません。</li>
+</ul>
+<p>以下の例では、一つ目のクエリにNoIndexScanを、二つ目のクエリにSeqScanをそれぞれ指定しています。</p>
+<pre>
+postgres=# CREATE FUNCTION hints_func(integer) RETURNS integer AS $$
+postgres$# DECLARE
+postgres$#     id  integer;
+postgres$#     cnt integer;
+postgres$# BEGIN
+postgres$#     SELECT <span class="strong">/*+ NoIndexScan(a) */</span> aid
+postgres$#         INTO id FROM pgbench_accounts a WHERE aid = $1;
+postgres$#     SELECT <span class="strong">/*+ SeqScan(a) */</span> count(*)
+postgres$#         INTO cnt FROM pgbench_accounts a;
+postgres$#     RETURN id + cnt;
+postgres$# END;
+postgres$# $$ LANGUAGE plpgsql;
+</pre>
+</dd>
+<dt>ヒント句内のオブジェクト名の文字ケース</dt>
+<dd>PostgreSQL は引用符で囲われないオブジェクト名を文字ケースを無視して扱いますが、pg_hint_plan は指定されたオブジェクト名の文字ケースはそのまま PostgreSQL の内部表現と比較します。つまり、ヒント句で TBL と指定した場合、データベース上で "TBL" と定義したもののみと合致し, TBL, tbl, Tbl など引用符で囲われないオブジェクト名とは合致しません。</dd>
+<dt>ヒント句内のオブジェクト名の引用符付け</dt>
+<dd>ヒントに記述するオブジェクト名や別名が括弧((、)のいずれか)、二重引用符(")、空白(スペース、タブ、改行のいずれか)を含む場合は、通常のSQL文で使う場合と同じように二重引用符(")で囲んでください。二重引用符を含むオブジェクト名は、全体を二重引用符で括ったうえで、内部に含む二重引用符を二重引用符でエスケープしてください(例: 「quoted"table"name」→「"quoted""table""name"」)。</dd>
+<dt>同一名称テーブルの区別</dt>
+<dd>スキーマ違いや同一テーブルの複数回使用などでクエリ中に同一名称のテーブルが複数回出現する場合は、テーブルに別名をつけてそれぞれのテーブルを区別してください。以下の例の1つ目のSQL文では、HashJoin(t1 t1)をヒントに指定したとき、ヒント句対象のオブジェクトが特定できずにエラーになっています。2つ目のSQL文では、各テーブルにptやstという別名をつけているため、実行計画作成時にヒントで指定した通りにHash Joinを選択しています。</p>
+<pre>
+postgres=# /*+ <span class="strong">HashJoin(t1 t1)</span>*/
+postgres-# EXPLAIN SELECT * FROM s1.t1
+postgres-# JOIN public.t1 ON (s1.t1.id=public.t1.id);
+INFO:  hint syntax error at or near "HashJoin(t1 t1)"
+<span class="strong">DETAIL:  Relation name "t1" is ambiguous.</span>
+                            QUERY PLAN
+------------------------------------------------------------------
+ Merge Join  (cost=337.49..781.49 rows=28800 width=8)
+   Merge Cond: (s1.t1.id = public.t1.id)
+   ->  Sort  (cost=168.75..174.75 rows=2400 width=4)
+         Sort Key: s1.t1.id
+         ->  Seq Scan on t1  (cost=0.00..34.00 rows=2400 width=4)
+   ->  Sort  (cost=168.75..174.75 rows=2400 width=4)
+         Sort Key: public.t1.id
+         ->  Seq Scan on t1  (cost=0.00..34.00 rows=2400 width=4)
+(8 行)
+
+postgres=# /*+ <span class="strong">HashJoin(pt st)</span> */
+postgres-# EXPLAIN SELECT * FROM s1.t1 st
+postgres-# JOIN public.t1 pt ON (st.id=pt.id);
+                             QUERY PLAN
+---------------------------------------------------------------------
+ <span class="strong">Hash Join</span>  (cost=64.00..1112.00 rows=28800 width=8)
+   Hash Cond: (st.id = pt.id)
+   ->  Seq Scan on t1 st  (cost=0.00..34.00 rows=2400 width=4)
+   ->  Hash  (cost=34.00..34.00 rows=2400 width=4)
+         ->  Seq Scan on t1 pt  (cost=0.00..34.00 rows=2400 width=4)
+(5 行)
+
+postgres=#</pre>
+</p>
+</dd>
+<dl>
+<dt>ビューおよびルールの中でアクセスされているテーブル</dt>
+<dd>ヒント句で指定した名称と一致すれば、ビュー定義や関数内クエリなどに出現するテーブルについても、ヒントを指定したクエリ内と同じようにヒント句が適用されます。このため、ヒント句の適用有無や適用するヒント句をそれぞれのテーブルで変えたい場合は、それぞれ異なる別名を指定してください。</br>
+以下の例では、ビュー定義で使われている「t1」という別名をSeqScanヒント句で指定したことで、表スキャンとビュー経由のスキャンの両方でSeq Scanが選択されています。ビュー定義で使用されている「t1」とは別の別名を実表に指定することで、個別にスキャン方式を制御できます。
+<pre>
+postgres=# CREATE VIEW view1 AS SELECT * FROM table1 <span class="strong">t1</span>;
+CREATE TABLE
+postgres=# /*+ SeqScan(<span class="strong">t1</span>) */
+postgres=# EXPLAIN SELECT * FROM table1 <span class="strong">t1</span> JOIN view1 t2 ON (t1.key = t2.key) WHERE t2.key = 1;
+                           QUERY PLAN
+-----------------------------------------------------------------
+ Nested Loop  (cost=0.00..358.01 rows=1 width=16)
+   ->  Seq Scan on table1 <span class="strong">t1</span>  (cost=0.00..179.00 rows=1 width=8)
+         Filter: (key = 1)
+   ->  Seq Scan on table1 <span class="strong">t1</span>  (cost=0.00..179.00 rows=1 width=8)
+         Filter: (key = 1)
+</pre>
+</dd>
+<dt>継承テーブル</dt>
+<dd>継承テーブルにスキャン方式のヒント句を指定する場合は、オブジェクト名として親テーブルの名称または別名を指定してください。全ての子テーブルに同じスキャン方式を選択します。子テーブルごとに別のスキャン方式を指定することはできません。</dd>
+
+<dt>マルチステートメント</dt>
+<dd>クエリをマルチステートメントで実行する場合は、ヒントの指定方法によって以下のように注意点が異なります。
+<dl>
+<dt>コメントでの指定</dt>
+<dd>1つ目のクエリで指定したヒントが全てのクエリで使用されます。2つ目以降のクエリに指定したヒントは無視されます。</dd>
+<dt>テーブルでの指定</dt>
+<dd>ヒントを指定したいクエリの定数部分を?に置き換えてから、全てのクエリを一つにまとめてヒント用テーブルに登録します。ただし、複数の動的クエリをマルチステートメントで実行する場合には対応していません。</dd>
+</dl>
+</dd>
+<dt>FROM句にVALUES式を使っている問い合わせ</dt>
+<dd>FROM句にVALUES式を使っている場合は、ヒント句のオブジェクト名に「*VALUES*」を指定することでヒントを与えることができる場合があります。 ただし複数のVALUESを使っている場合は内部的には区別がつかないためヒントを与えることはできません。
+<pre>
+postgres=# /*+ <span class="strong">MergeJoin(a *VALUES*)</span> */
+postgres-# EXPLAIN SELECT *
+postgres-#    FROM pgbench_accounts a
+postgres-#    JOIN (VALUES (1,1),(2,2)) <span class="strong">v</span> (vid, vbalance) ON a.aid = v.vid
+postgres-#   ORDER BY a.aid;
+                                                  QUERY PLAN
+---------------------------------------------------------------------------------------------------------------
+ <span class="strong">Merge Join</span>  (cost=0.04..4497.33 rows=2 width=105)
+   Merge Cond: (a.aid = "*VALUES*".column1)
+   ->  Index Scan using pgbench_accounts_pkey on pgbench_accounts a  (cost=0.00..4247.26 rows=100000 width=97)
+   ->  Sort  (cost=0.04..0.04 rows=2 width=8)
+         Sort Key: "*VALUES*".column1
+         ->  Values Scan on <span class="strong">"*VALUES*"</span>  (cost=0.00..0.03 rows=2 width=8)
+postgres=#
+</pre>
+</dd>
+</dl>
+
+<dt>副問い合わせ結果</dt>
+<dd>以下のような形式の副問い合わせでは外側の文への併合が行われず「ANY_subquery」という名前の独立した副問合せとして残される場合があります。このような副問合せが一つしかない場合は ANY_subquery という名前でこの副問合せを特定することができます。
+<ul>
+<li>IN (SELECT ... { <span class="strong">LIMIT | OFFSET 等</span>} ... )</li>
+<li>ANY (SELECT ... { <span class="strong">LIMIT | OFFSET 等</span>} ...)</li>
+<li>SOME (SELECT ... { <span class="strong">LIMIT | OFFSET 等</span>} ...)</li>
+</ul>
+以下の例では、そのことを利用して Hash Joinを強制しています。
+<pre>
+postgres=# /*+HashJoin(a1 ANY_subquery)*/
+postgres=# EXPLAIN SELECT *
+postgres=#    FROM pgbench_accounts a1
+postgres=#   WHERE aid IN (SELECT bid FROM pgbench_accounts a2 LIMIT 10);
+                                         QUERY PLAN
+
+---------------------------------------------------------------------------------------------
+ Hash Semi Join  (cost=0.49..2903.00 rows=1 width=97)
+   Hash Cond: (a1.aid = a2.bid)
+   ->  Seq Scan on pgbench_accounts a1  (cost=0.00..2640.00 rows=100000 width=97)
+   ->  Hash  (cost=0.36..0.36 rows=10 width=4)
+         ->  Limit  (cost=0.00..0.26 rows=10 width=4)
+               ->  Seq Scan on pgbench_accounts a2  (cost=0.00..2640.00 rows=100000 width=4)
+(6 rows)
+
+postgres=#
+</pre>
+
+<dt>IndexOnlyScanヒント句</dt>
+<dd>IndexOnlyScanヒントで指定されているインデックスで index only scan が実行できない場合は、index scan を他のインデックスで実行する可能性があります。</dd>
+
+<dt>NoIndexScanヒントの挙動について</dt>
+<dd>NoIndexScanヒント句を指定した場合は、Index ScanだけでなくIndex Only Scanも選択されません。</dd>
+</dl>
+
+<dt>UNION に対する並列実行ヒント</dt>
+<dd>UNIONは直下のサブクエリが全て並列実行可能な場合にだけ並列実行を行います。一方ですべてのサブクエリが並列実行可能な場合は、そのうちの一つで並列実行を強制するとコスト比較の結果UNION全体が並列実行されることになります。ただし並列実行ヒントによる並列実行の禁止を行った場合はそのスキャンは並列実行不可となります。
+</dd>
+</dl>
+
+<dt>Set ヒントでの pg_hint_plan 自身の制御変数の設定</dt>
+<dd>pg_hint_plan 自身の挙動を設定する変数を Set ヒントで変更した場合は期待通りに動作しない場合があります。</dd>
+<ul>
+<li>enable_hint, enable_hint_tables の設定ヒントはログ上は「使用済み」と出ますが、実際には無視されています。</li>
+<li>debug_print と message_level の変更は処理の途中から影響を与えます。</li>
+</ul>
+</dd>
+
+<h2>ヒントのパースエラーについて</h2>
+<dt>構文エラー</dt>
+<dd>ヒント句の記述に構文上の誤りがあった場合、pg_hint_planは誤った記述より前のヒント句のみ有効とし、誤った記述以降のヒント句を無視してクエリを実行します。誤りの内容はpg_hint_plan.parse_messagesで指定したレベルでサーバログに記録されます。
+<ul>
+<li>ヒント句名を間違っている。</li>
+<li>オブジェクト指定を正しく括弧で囲っていない。</li>
+<li>オブジェクト名を空白で区切っていない。</li>
+</ul>
+</dd>
+<dt>オブジェクト指定エラー</dt>
+<dd>pg_hint_planは、ヒント句対象のオブジェクト指定に誤りがあった場合、pg_hint_planは正常に解析できたヒントのみを適用して、それ以外を無視します。誤りの内容はpg_hint_plan.parse_messagesで指定したレベルでサーバログに記録されます。
+<ul>
+</dd>
+
+<dt>重複したヒント</dt>
+<dd>同じオブジェクトに対して同じグループのヒント句を重複して指定した場合は、各グループで最後に指定したヒント句を使用します。</dd>
+<dt>ネストしたブロックコメント</dt>
+<dd>pg_hint_planでは、ヒントを指定したブロックコメントにネストしたブロックコメントを含めることができません。ネストしたブロックコメントを含めた場合は、誤った記述に関する情報を出力しますがエラー終了しません。ヒントを無視してクエリを実行します。</dd>
+<dt>メッセージの出力レベル</dt>
+<dd>ヒントに誤りがあった場合に出力されるメッセージのレベルは、基本的にはpg_hint_plan.parse_messagesに指定したレベルです。ただし、ヒント句に指定したオブジェクトの長さが識別子の最大長(デフォルトでは63バイト)を超えた際に切り詰めた場合は、NOTICEで出力します。</dd>
+
+<h2>注意事項</h2>
+<dt>プランナパラメータの影響</dt>
+<dd>FROM句の要素数が from_collapse_limit 以上または join_collapse_limit を超える場合には、結合順序のヒント句は正しく動作しません。また、FROM句の要素数が geqo_threshold 以上の場合は、結合順序のヒント句、および結合方式のヒント句は動作しません。ヒント句が使われるようにするには、これらのGUCパラメータの値を十分に大きくしてください。</dd>
+<dt>実行不能なプランを指定するヒント</dt>
+<dd>ヒントで指定した結果正しく実行できない実行計画が生成される場合は、実行可能なプランに強制的に修正します。実行不能な実行計画例を以下に示します。
+<ul>
+<li>特殊な場合を除いた FULL OUTER JOINに対する Nested Loop。</li>
+<li>WHERE句やJOIN条件などに指定していない列のみを含むインデックス。</li>
+<li>検索条件にctidを指定しない場合の Tid Scan。</li>
+</ul>
+</dd>
+<dt>ECPGにおける制限</dt>
+<dd>ECPGで実装したアプリケーションから発行するクエリにヒントをコメントで指定した場合、実行計画を制御できません。これは、CプリプロセッサがCコードに変換するタイミングで、全てのブロックコメントを取り除いてしまうためです。ただし、EXECUTEコマンドで実行する動的SQLに含まれるコメントは使用可能です。</dd>
+<dt>異なるヒントを与えた同一クエリの pg_stat_statements での扱い</dt>
+<dd>pg_stat_statements ではクエリIDの生成の際にコメントは無視されます。そのため与えているヒントが異なる同一のクエリは一つのクエリとして集計されます。</dd>
+
+</dl>
+
+<h2 id="requirement">動作環境</h2>
+pg_hint_plan12 1.3 は PostgreSQL 12 のみをサポートします。
+<dl>
+<dt>PostgreSQL</dt>
+  <dd>バージョン 12</dd>
+<dt>動作確認済みOS</dt>
+  <dd>CentOS 8.2</dd>
+</dl>
+
+<h2 id="seealso">関連項目</h2>
+<h3 id="postgresql_document">PostgreSQLドキュメント</h3>
+<a href="http://www.postgresql.jp/document/current/html/sql-explain.html">EXPLAIN</a>
+<a href="http://www.postgresql.jp/document/current/html/sql-set.html">SET</a>
+<a href="http://www.postgresql.jp/document/current/html/runtime-config.html">サーバの設定</a>
+<a href="http://www.postgresql.jp/document/current/html/parallel-plans.html">パラレルプラン</a>
+<hr>
+
+<div class="navigation">
+  <a href="pg_hint_plan-ja.html">pg_hint_plan</a>
+</div>
+
+<p class="footer">Copyright (c) 2012-2020, NIPPON TELEGRAPH AND TELEPHONE CORPORATION</p>
+</body>
+</html>
diff --git a/gpcontrib/pg_hint_plan/doc/pg_hint_plan.html b/gpcontrib/pg_hint_plan/doc/pg_hint_plan.html
new file mode 100755
index 0000000000..c0508d8226
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/doc/pg_hint_plan.html
@@ -0,0 +1,508 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD html 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en_US">
+<head>
+<title>pg_hint_plan</title>
+<!-- Uncoment after the tool has been hosted somewhere.
+<link rel="home" title="pg_hint_plan" href="index.html">
+-->
+<link rel="stylesheet" type="text/css" href="style.css">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<!--
+<style type="text/css">
+h2 { border-style:solid none none none; margin-top: 2em; }
+h3 { margin-top: 2em; }
+dt { margin-top: 0.5em; margin-bottom: 0.3em;}
+pre { margin: 0 2em 0 2em; padding:0.3em; border-style: solid; border-width:0.1em; border-color: #97A69F; background-color: #DEFFEF; }
+</style>
+-->
+</head>
+
+<body>
+<h1 id="pg_hint_plan">pg_hint_plan 1.3</h1>
+<div class="navigation">
+  <a href="pg_hint_plan.html">pg_hint_plan</a>
+</div>
+<hr>
+
+<div class="index">
+<ol>
+<li><a href="#name">Name</a></li>
+<li><a href="#synopsis">Synopsis</a></li>
+<li><a href="#description">Description</a>
+<li><a href="#install">Installation</a></li>
+<li><a href="#uninstall">Uninstallation</a></li>
+<li><a href="#examples">Hint descriptions</a></li>
+<li><a href="#hint_syntax">Hint syntax</a></li>
+<li><a href="#restrictions">Restrictions</a></li>
+<li><a href="#techniques">Techniques to hint on disired targets</a></li>
+<li><a href="#errors">Errors of hints</a></li>
+<li><a href="#func_limits">Functional limitations</a></li>
+<li><a href="#requirement">Requirements</a></li>
+<li><a href="#seealso">See Also</a></li>
+<li><a href="hint_list.html">Appendix A. Hints list</a></li>
+</div>
+
+<h2 id="name">Name</h2>
+<p>pg_hint_plan -- controls execution plan with hinting phrases in comment of special form.</p>
+
+<h2 id="synopsis">Synopsis</h2>
+<p>PostgreSQL uses cost based optimizer, which utilizes data statistics, not static rules. The planner (optimizer) esitimates costs of each possible execution plans for a SQL statement then the execution plan with the lowest cost finally be executed.  The planner does its best to select the best best execution plan, but not perfect, since it doesn't count some properties of the data, for example, correlation between columns.</p>
+<p>pg_hint_plan makes it possible to tweak execution plans using so-called "hints", which are simple descriptions in the SQL comment of special form.</p>
+
+<h2 id="description">Description</h2>
+
+<h3 id="hint-rule">Basic Usage</h3>
+<p>pg_hint_plan reads hinting phrases in a comment of special form given with the target SQL statement. The special form is beginning by the character sequence "/*+" and ends with "*/". Hint phrases are consists of hint name and following parameters enclosed by parentheses and delimited by spaces. Each hinting phrases can be delimited by new lines for readability.</p>
+
+<p>In the example below , hash join is selected as the joining method and scanning pgbench_accounts by sequential scan method.</p>
+<pre>
+postgres=# /*+
+postgres*#    <span class="strong">HashJoin(a b)</span>
+postgres*#    <span class="strong">SeqScan(a)</span>
+postgres*#  */
+postgres-# EXPLAIN SELECT *
+postgres-#    FROM pgbench_branches b
+postgres-#    JOIN pgbench_accounts a ON b.bid = a.bid
+postgres-#   ORDER BY a.aid;
+                                      QUERY PLAN
+---------------------------------------------------------------------------------------
+ Sort  (cost=31465.84..31715.84 rows=100000 width=197)
+   Sort Key: a.aid
+   ->  <span class="strong">Hash Join</span>  (cost=1.02..4016.02 rows=100000 width=197)
+         Hash Cond: (a.bid = b.bid)
+         ->  <span class="strong">Seq Scan on pgbench_accounts a</span>  (cost=0.00..2640.00 rows=100000 width=97)
+         ->  Hash  (cost=1.01..1.01 rows=1 width=100)
+               ->  Seq Scan on pgbench_branches b  (cost=0.00..1.01 rows=1 width=100)
+(7 rows)
+
+postgres=# </pre>
+
+<h2 id="examples">The hint table</h2>
+<p> Hints are described in a comment in a special form in the above
+section. This is inconvenient in the case where queries cannot be
+edited. In the case hints can be placed in a special table named
+"hint_plan.hints". The table consists of the following columns.</p>
+<table>
+<thead>
+<tr>
+<tr><th>column</th><th>description</th></tr>
+</tr></thead>
+<tbody>
+<tr><td>id</td>
+  <td>Unique number to identify a row for a hint. This column is filled automatically by sequence.</td></tr>
+<tr><td>norm_query_string</td>
+  <td>A pattern matches to the query to be hinted. Constants in the query have to be replace with '?' as in the following example. White space is significant in the pattern.</td></tr>
+<tr><td>application_name</td>
+  <td>The value of application_name of sessions to apply the hint. The hint in the example below applies to sessions connected from psql. An empty string means sessions of any application_name.</td></tr>
+<tr><td>hints</td>
+  <td>Hint phrase. This must be a series of hints excluding surrounding comment marks.</td></tr>
+</tbody>
+</table>
+
+<p>The following example shows how to operate with the hint table.</p>
+<pre>
+<span class="strong">postgres=#</span> INSERT INTO hint_plan.hints(norm_query_string, application_name, hints)
+<span class="strong">postgres-#</span>     VALUES (
+<span class="strong">postgres(#</span>         'EXPLAIN (COSTS false) SELECT * FROM t1 WHERE t1.id = ?;',
+<span class="strong">postgres(#</span>         '',
+<span class="strong">postgres(#</span>         'SeqScan(t1)'
+<span class="strong">postgres(#</span>     );
+INSERT 0 1
+<span class="strong">postgres=#</span> UPDATE hint_plan.hints
+<span class="strong">postgres-#</span>    SET hints = 'IndexScan(t1)'
+<span class="strong">postgres-#</span>  WHERE id = 1;
+UPDATE 1
+<span class="strong">postgres=#</span> DELETE FROM hint_plan.hints
+<span class="strong">postgres-#</span>  WHERE id = 1;
+DELETE 1
+<span class="strong">postgres=#</span>
+</pre>
+<p>The hint table is owned by the creator user and having the default previledges at the time of creation.
+during CREATE EXTENSION. Table hints are prioritized than comment hits.</p>
+
+<h3 id="hint-group">The types of hints</h3>
+<p>Hinting phrases are classified into six types based on what kind of object and how they can affect planning. Scaning methods, join methods, joining order, row number correction, parallel query and GUC setting. You will see the lists of hint phrases of each type in <a href="hint_list.html">Hint list</a>.</p>
+
+<h4>Hints for scan methods </h4>
+<p>Scan method hints enforce specific scanning method on the target table. pg_hint_plan recognizes the target table by alias names if any. They are 'SeqScan' , 'IndexScan' and so on in this kind of hint.</p>
+<p>Scan hints are effective on ordinary tables, inheritance tables, UNLOGGED tables, temporary tables and  system catalogs. External(foreign) tables, table functions, VALUES clause, CTEs, views and subquiries are not affected.</p>
+<pre>
+<span class="strong">postgres=# /*+</span>
+<span class="strong">postgres*#     SeqScan(t1)</span>
+<span class="strong">postgres*#     IndexScan(t2 t2_pkey)</span>
+<span class="strong">postgres*#  */</span>
+<span class="strong">postgres-#</span> SELECT * FROM table1 t1 JOIN table table2 t2 ON (t1.key = t2.key);
+</pre>
+
+
+<h4>Hints for join methods</h4>
+<p>Join method hints enforce the join methods of the joins involving specified tables. </p>
+<p>This can affect on joins only on ordinary tables, inheritance tables, UNLOGGED tables, temporary tables, external (foreign) tables, system catalogs, table functions, VALUES command results and CTEs are allowed to be in the parameter list. But joins on views and sub query are not affected.</p>
+
+<h4>Hint for joining order</h4>
+<p> This hint "Leading" enforces the order of join on two or more tables. There are two ways of enforcing. One is enforcing specific order of joining but not restricting direction at each join level. Another enfoces join direction additionaly. Details are seen in the <a href="hint_list.html">hint list</a> table.</p>
+
+<pre>
+<span class="strong">postgres=# /*+</span>
+<span class="strong">postgres*#     NestLoop(t1 t2)</span>
+<span class="strong">postgres*#     MergeJoin(t1 t2 t3)</span>
+<span class="strong">postgres*#     Leading(t1 t2 t3)</span>
+<span class="strong">postgres*#  */</span>
+<span class="strong">postgres-#</span> SELECT * FROM table1 t1
+<span class="strong">postgres-#</span>     JOIN table table2 t2 ON (t1.key = t2.key)
+<span class="strong">postgres-#</span>     JOIN table table3 t3 ON (t2.key = t3.key);
+</pre>
+
+<h4>Hint for row number correction</h4>
+<p>This hint "Rows" corrects row number misestimation of joins that comes from restrictions of the planner. </p>
+
+<pre>
+<span class="strong">postgres=# /*+ Rows(a b #10) */</span> SELECT... ; Sets rows of join result to 10
+<span class="strong">postgres=# /*+ Rows(a b +10) */</span> SELECT... ; Increments row number by 10
+<span class="strong">postgres=# /*+ Rows(a b -10) */</span> SELECT... ; Subtracts 10 from the row number.
+<span class="strong">postgres=# /*+ Rows(a b *10) */</span> SELECT... ; Makes the number 10 times larger.
+</pre>
+
+<h4>Hint for parallel plan</h4>
+<p>This hint "Parallel" enforces parallel execution configuration on
+scans. The third parameter specifies the strength of enfocement. "soft" means that pg_hint_plan only changes max_parallel_worker_per_gather and leave all others to planner. "hard" changes other planner parameters so as to forcibly apply the number. This can affect on ordinary tables, inheritnce parents, unlogged
+tables and system catalogues. External tables, table functions, values clause, CTEs, views and subqueries are not affected. Internal tables of a view can be specified by its real name/alias as the target object. The following example shows that the query is enforced differently on each table.</p>
+
+<pre>
+<span class="strong">postgres=#</span> explain <span class="strong">/*+ Parallel(c1 3 hard) Parallel(c2 5 hard) */</span>
+       SELECT c2.a FROM c1 JOIN c2 ON (c1.a = c2.a);
+                                  QUERY PLAN                                   
+-------------------------------------------------------------------------------
+ Hash Join  (cost=2.86..11406.38 rows=101 width=4)
+   Hash Cond: (c1.a = c2.a)
+   ->  Gather  (cost=0.00..7652.13 rows=1000101 width=4)
+         <span class="strong">Workers Planned: 3</span>
+         ->  Parallel Seq Scan on <span class="strong">c1</span>  (cost=0.00..7652.13 rows=322613 width=4)
+   ->  Hash  (cost=1.59..1.59 rows=101 width=4)
+         ->  Gather  (cost=0.00..1.59 rows=101 width=4)
+               <span class="strong">Workers Planned: 5</span>
+               ->  Parallel Seq Scan on <span class="strong">c2</span>  (cost=0.00..1.59 rows=59 width=4)
+
+<span class="strong">postgres=#</span> EXPLAIN <span class="strong">/*+ Parallel(tl 5 hard) */</span> SELECT sum(a) FROM tl;
+                                    QUERY PLAN                                  
+-----------------------------------------------------------------------------------
+ <span class="strong">Finalize Aggregate</span>  (cost=693.02..693.03 rows=1 width=8)
+   ->  Gather  (cost=693.00..693.01 rows=5 width=8)
+         <span class="strong">Workers Planned: 5</span>
+         ->  <span class="strong">Partial Aggregate</span>  (cost=693.00..693.01 rows=1 width=8)
+               ->  Parallel Seq Scan on tl  (cost=0.00..643.00 rows=20000 width=4)
+</pre>
+</dd>
+
+
+</pre>
+
+
+<h4>GUC parameters temporarily setting</h4>
+<p>'Set' hint changes GUC parameters just while planning. GUC parameter shown in <a href="http://www.postgresql.org/docs/current/static/runtime-config-query.html">Query Planning</a> can have the expected effects on planning unless any other hint conflicts with the planner method configuration parameters. The last one among hints on the same GUC parameter makes effect. <a href="#hint-GUC">GUC parameters for pg_hint_plan</a> are also settable by  this hint but it won't work as your expecta [...]
+<pre>
+postgres=# <span class="strong">/*+ Set(random_page_cost 2.0) */</span>
+postgres-# SELECT * FROM table1 t1 WHERE key = 'value';
+...
+</pre>
+
+<h3 id="hint-GUC">GUC parameters for pg_hint_plan</h3>
+<p>GUC parameters below affect the behavior of pg_hint_planpg_hint_plan.</p>
+<table>
+<thead>
+<tr>
+<tr><th>Parameter name</th><th>discription</th><th>Default</th></tr>
+</tr></thead>
+<tbody>
+<tr><td>pg_hint_plan.enable_hint</td>
+  <td>True enbles pg_hint_plan.</td><td>on</td></tr>
+<tr><td>pg_hint_plan.enable_hint_table</td>
+  <td>True enbles hinting by table. true or false.</td><td>off</td></tr>
+<tr><td>pg_hint_plan.parse_messages</td>
+  <td>Specifies the log level of hint parse error. Valid values are error, warning, notice, info, log, debug<n>.</td><td>INFO</td></tr>
+<tr><td>pg_hint_plan.debug_print</td>
+  <td>Controls debug print and verbosity. Valid vaiues are off, on, detailed and verbose.</td><td>off</td></tr>
+<tr><td>pg_hint_plan.message_level</td>
+  <td>Specifies message level of debug print. Valid values are error, warning, notice, info, log, debug<n>.</td><td>LOG</td></tr>
+</tbody>
+</table>
+<h2 id="install">Installation</h2>
+This section describes the installation steps.
+<h3 id="build">building binary module</h3>
+<p>Simply run "make" in the top of the source tree, then "make install" as appropriate user. The PATH environment variable should be set properly for the target PostgreSQL for this process. </p>
+<pre>
+$ tar xzvf pg_hint_plan-1.x.x.tar.gz
+$ cd pg_hint_plan-1.x.x
+$ make
+$ su
+# make install
+</pre>
+
+<h3 id="hint-load">Loding pg_hint_plan</h3>
+<p>Basically pg_hint_plan does not requires CREATE EXTENSION. Simply loading it by LOAD command will activate it and of course you can load it globally by setting shared_preload_libraries in postgresql.conf. Or you might be interested in ALTER USER SET/ALTER DATABASE SET for automatic loading for specific sessions. 
+<pre>
+postgres=# LOAD 'pg_hint_plan';
+LOAD
+postgres=# </pre></p>
+
+<p>Do CREATE EXTENSION and SET pg_hint_plan.enable_hint_tables TO on if you are planning to hint tables.</p>
+
+
+<h2 id="uninstall">Unistallation</h2>
+<p>"make uninstall" in the top directory of source tree will uninstall the installed files if you installed from the source tree and it is left available. </p>
+
+<pre>
+$ cd pg_hint_plan-1.x.x
+$ su
+# make uninstall
+</pre>
+
+<h2 id="hint_syntax">Details in hinting</h2>
+<dl>
+<dt>Syntax and placement</dt>
+<dd>pg_hint_plan reads hints from only the first block comment and any characters except alphabets, digits, spaces, underscores, commas and parentheses stops parsing immediately. In the following example HashJoin(a b) and SeqScan(a) are parsed as hints but IndexScan(a) and MergeJoin(a b) are not.
+
+<pre>
+<span class="strong">postgres=# /*+</span>
+<span class="strong">postgres*#    HashJoin(a b)</span>
+<span class="strong">postgres*#    SeqScan(a)</span>
+<span class="strong">postgres*#  */</span>
+<span class="strong">postgres-# /*+ IndexScan(a) */</span>
+<span class="strong">postgres-#</span> EXPLAIN SELECT <span class="strong">/*+ MergeJoin(a b) */</span> *
+<span class="strong">postgres-#</span>    FROM pgbench_branches b
+<span class="strong">postgres-#</span>    JOIN pgbench_accounts a ON b.bid = a.bid
+<span class="strong">postgres-#</span>   ORDER BY a.aid;
+                                      QUERY PLAN
+---------------------------------------------------------------------------------------
+ Sort  (cost=31465.84..31715.84 rows=100000 width=197)
+   Sort Key: a.aid
+   ->  <span class="strong">Hash Join</span>  (cost=1.02..4016.02 rows=100000 width=197)
+         Hash Cond: (a.bid = b.bid)
+         ->  <span class="strong">Seq Scan on pgbench_accounts a</span>  (cost=0.00..2640.00 rows=100000 width=97)
+         ->  Hash  (cost=1.01..1.01 rows=1 width=100)
+               ->  Seq Scan on pgbench_branches b  (cost=0.00..1.01 rows=1 width=100)
+(7 rows)
+
+postgres=# </pre>
+</dd>
+
+<dt>Using with PL/pgSQL</dt>
+<dd>pg_hint_plan works for queries in PL/pgSQL scripts with some restrictions.
+<ul>
+ <li>Hints affect only on the following kind of queires.
+ <ul>
+  <li>Queries that returns one row. (SELECT, INSERT, UPDATE and DELETE)</li>
+  <li>Queries that returns multiple rows. (RETURN QUERY)</li>
+  <li>Dynamic SQL statements. (EXECUTE)</li>
+  <li>Cursor open. (OPEN)</li>
+  <li>Loop over result of a query (FOR)</li>
+ </ul>
+
+ <li>A hint comment have to be placed after the first word in a query
+     as the following since preceding comments are not sent as a part
+     of the query.</li>
+</ul>
+<pre>
+postgres=# CREATE FUNCTION hints_func(integer) RETURNS integer AS $$
+postgres$# DECLARE
+postgres$#     id  integer;
+postgres$#     cnt integer;
+postgres$# BEGIN
+postgres$#     SELECT <span class="strong">/*+ NoIndexScan(a) */</span> aid
+postgres$#         INTO id FROM pgbench_accounts a WHERE aid = $1;
+postgres$#     SELECT <span class="strong">/*+ SeqScan(a) */</span> count(*)
+postgres$#         INTO cnt FROM pgbench_accounts a;
+postgres$#     RETURN id + cnt;
+postgres$# END;
+postgres$# $$ LANGUAGE plpgsql;
+</pre>
+</dd>
+
+<dt>Letter case in the object names</dt>
+<dd>Unlike the way PostgreSQL handles object names, pg_hint_plan compares bare object names in hints against the database internal object names in case sensitive way. Therefore an object name TBL in a hint matches only "TBL" in database and does not match any unquoted names like TBL, tbl or Tbl.
+</dd>
+
+<dt>Escaping special chacaters in object names</dt>
+<dd>The objects as the hint parameter should be enclosed by double quotes if they includes parentheses, double quotes and white spaces. The escaping rule is the same as PostgreSQL.
+</dd>
+
+<h3>Distinction between multiple occurances of a table</h3>
+<dd>pg_hint_plan identifies the target object by using aliases if
+exists. This behavior is usable to point a specific occurance
+among multiple occurances of one table.
+<pre>
+<span class="strong">postgres=# /*+ HashJoin(t1 t1) */</span>
+<span class="strong">postgres-#</span> EXPLAIN SELECT * FROM s1.t1
+<span class="strong">postgres-#</span> JOIN public.t1 ON (s1.t1.id=public.t1.id);
+INFO:  hint syntax error at or near "HashJoin(t1 t1)"
+<span class="strong">DETAIL:  Relation name "t1" is ambiguous.</span>
+...
+<span class="strong">postgres=# /*+ HashJoin(pt st) */</span>
+<span class="strong">postgres-#</span> EXPLAIN SELECT * FROM s1.t1 st
+<span class="strong">postgres-#</span> JOIN public.t1 pt ON (st.id=pt.id);
+                             QUERY PLAN
+---------------------------------------------------------------------
+ <span class="strong">Hash Join</span>  (cost=64.00..1112.00 rows=28800 width=8)
+   Hash Cond: (st.id = pt.id)
+   ->  Seq Scan on t1 st  (cost=0.00..34.00 rows=2400 width=4)
+   ->  Hash  (cost=34.00..34.00 rows=2400 width=4)
+         ->  Seq Scan on t1 pt  (cost=0.00..34.00 rows=2400 width=4)
+</pre>
+</dd>
+
+<dt>Underlying tables of views or rules</dt>
+<dd>Hints are not applicable on views itself, but they can affect the
+queries within if the object names match the object names in the
+expanded query on the view. Assigning aliases to the tables in a view
+enables them to be manipulated from outside the view.
+<pre>
+<span class="strong">postgres=#</span> CREATE VIEW v1 AS SELECT * FROM <span class="strong">t2</span>;
+<span class="strong">postgres=#</span> EXPLAIN <span class="strong">/*+ HashJoin(t1 v1) */</span>
+          SELECT * FROM t1 JOIN v1 ON (c1.a = v1.a);
+                            QUERY PLAN                            
+------------------------------------------------------------------
+ Hash Join  (cost=3.27..18181.67 rows=101 width=8)
+   Hash Cond: (t1.a = t2.a)
+   ->  Seq Scan on t1  (cost=0.00..14427.01 rows=1000101 width=4)
+   ->  Hash  (cost=2.01..2.01 rows=101 width=4)
+         ->  Seq Scan on t2  (cost=0.00..2.01 rows=101 width=4)
+</pre>
+</dd>
+
+<dt>Inheritance tables</dt>
+<dd>Hints can point only the parent of an inheritance tables and the
+hint affect all the inheritance. Hints simultaneously point directly
+to children are not in effect.
+</dd>
+
+<dt>Hinting on multistatements</dt>
+<dd>One multistatement can have exactly one hint comment and the hints affects all of the individual statement in the multistatement. Notice that the seemingly multistatement on the interactive interface of psql is internally a sequence of single statements so hints affects only on the statement just following.</dd>
+
+<dt>VALUES expressions</dt>
+<dd>VALUES expressions in FROM clause are named as *VALUES* internally
+so it is hintable if it is the only VALUES in a query. Two or more
+VALUES expressions in a query seems distinguishable looking its
+explain result. But in reality it is mere a cosmetic and they are not
+distinguisable.
+<pre>
+<span class="strong">postgres=#</span> <span class="strong">/*+ MergeJoin(*VALUES*_1 *VALUES*) */</span>
+      EXPLAIN SELECT * FROM (VALUES (1, 1), (2, 2)) v (a, b)
+      JOIN (VALUES (1, 5), (2, 8), (3, 4)) w (a, c) ON v.a = w.a;
+INFO:  pg_hint_plan: hint syntax error at or near "MergeJoin(*VALUES*_1 *VALUES*) "
+<span class="strong">DETAIL:  Relation name "*VALUES*" is ambiguous.</span>
+                               QUERY PLAN                                
+-------------------------------------------------------------------------
+ Hash Join  (cost=0.05..0.12 rows=2 width=16)
+   Hash Cond: ("*VALUES*_1".column1 = "*VALUES*".column1)
+   ->  Values Scan on "*VALUES*_1"  (cost=0.00..0.04 rows=3 width=8)
+   ->  Hash  (cost=0.03..0.03 rows=2 width=8)
+         ->  Values Scan on "*VALUES*"  (cost=0.00..0.03 rows=2 width=8)
+</pre>
+</dd>
+
+<h3>Subqueries</h3>
+<dd>
+<p>Subqueries in the following context occasionally can be hinted using the
+name "ANY_subquery".</p>
+<pre>
+IN (SELECT ... {<span class="strong">LIMIT | OFFSET</span> ...} ...)
+= ANY (SELECT ... {<span class="strong">LIMIT | OFFSET</span> ...} ...)
+= SOME (SELECT ... {<span class="strong">LIMIT | OFFSET</span> ...} ...)
+</pre>
+<p>For these syntaxes, planner internally assigns the name to the subquery when planning joins on tables including it, so join hints are applicable on such joins using the implicit name as the following.</p>
+<pre>
+<span class="strong">postgres=# /*+HashJoin(a1 ANY_subquery)*/</span>
+<span class="strong">postgres=#</span> EXPLAIN SELECT *
+<span class="strong">postgres=#</span>    FROM pgbench_accounts a1
+<span class="strong">postgres=#</span>   WHERE aid IN (SELECT bid FROM pgbench_accounts a2 LIMIT 10);
+                                         QUERY PLAN
+
+---------------------------------------------------------------------------------------------
+ <span class="strong">Hash Semi Join</span>  (cost=0.49..2903.00 rows=1 width=97)
+   Hash Cond: (a1.aid = a2.bid)
+   ->  Seq Scan on pgbench_accounts a1  (cost=0.00..2640.00 rows=100000 width=97)
+   ->  Hash  (cost=0.36..0.36 rows=10 width=4)
+         ->  Limit  (cost=0.00..0.26 rows=10 width=4)
+               ->  Seq Scan on pgbench_accounts a2  (cost=0.00..2640.00 rows=100000 width=4)
+</pre>
+</dd>
+
+<dt>Using IndexOnlyScan hint</dt>
+<dd>Index scan may unexpectedly performed on another index when the index specifed in IndexOnlyScan hint cannot perform index only scan.</dd>
+
+<dt>Behavior of NoIndexScan</dt>
+<dd>NoIndexScan hint involes NoIndexOnlyScan.</dd>
+
+<dt>Parallel hint and UNION</dt>
+<dd>A UNION can run in parallel only when all underlying subqueries
+are parallel-safe. Conversely enforcing parallel on any of
+the subqueries let a parallel-executable UNION run in
+parallel. Meanwhile, a parallel hint with zero workers hinhibits a scan
+from executed in parallel.</dd>
+
+<dt>Setting pg_hint_plan parameters by Set hints</dt>
+<dd><p>pg_hint_plan paramters change the behavior of itself so some parameters doesn't work as expected.</p>
+<ul>
+<li>Hints to change enable_hint, enable_hint_tables are ignored even though they are reported as "used hints" in debug logs.</li>
+<li>Setting debug_print and message_level works from midst of the processing of the target query.</li>
+</ul>
+</dd>
+</dl>
+
+<h2 id="errors">Errors</h2>
+<p>pg_hint_plan stops parsing on any error and uses hints already parsed on the most cases. Followings are the typical errors.</p>
+<dl>
+<dt>Syntax errors </dt>
+<dd>Any syntactical errors or wrong hint names are reported as an syntax error. These errors are reported in the server log with the message level which specified by pg_hint_plan.message_level if pg_hint_plan.debug_print is on and aboves.</dd>
+<dt>Object misspecifications</dt>
+<dd>Object misspecifications results silent ingorance of the hints. This kind of error is reported as "not used hints" in the server log by the same condtion to syntax errors.</dd>
+
+<dt>Redundant or conflicting hints</dt>
+<dd>The last hint will be active when redundant hints or hints conflicting with each other. This kind of error is reported as "duplication hints" in the server log by the same condition to syntax errors.</dd>
+
+<dt>Nested comments</dt>
+<dd>Hint comment cannot include another block comment within. If pg_hint_plan finds it, differently from other erros, it stops parsing and abandans all hints already parsed. This kind of error is reported in the same manner as other errors. </dd>
+
+<h2 id="func_limits">Functional limitations</h2>
+<dt>Influences of some of planner GUC parameters</dt>
+<dd>The planner does not try to consider joining order for FROM clause entries more than from_collapse_limit. pg_hint_plan cannot affect joining order as expected for the case.</dd>
+
+<dt>Hints trying to enforce unexecutable plans </dt>
+<dd>Planner chooses any executable plans when the enforced plan cannot be executed.
+<ul>
+<li>FULL OUTER JOIN to use nested loop</li>
+<li>To use indexes that does not have columns used in quals</li>
+<li>To do TID scans for queries without ctid conditions</li>
+</ul>
+</dd>
+
+<dt>Queries in ECPG</dt>
+<dd>ECPG removes comments in queries written as embedded SQLs so hints cannot be passed form those queries. The only exception is that EXECUTE command passes given string unmodifed. Please consider hint tables in the case.</dd>
+
+<dt>Work with pg_stat_statements</dt>
+<dd>pg_stat_statements generates a query id ignoring comments. As the result the identical queires with different hints are summerized as the same query.</dd>
+
+<h2 id="requirement">Requirements</h2>
+pg_hint_plan12 1.3 requires PostgreSQL 12.
+<dl>
+<dt>PostgreSQL versions tested</dt>
+  <dd>Version 12</dd>
+<dt>OS versions tested</dt>
+  <dd>CentOS 8.2</dd>
+</dl>
+
+<h2 id="seealso">See also</h2>
+<h3 id="postgresql_document">PostgreSQL documents</h3>
+<a href="http://www.postgresql.org/docs/current/static/sql-explain.html">EXPLAIN</a>
+<a href="http://www.postgresql.org/docs/current/static/sql-set.html">SET</a>
+<a href="http://www.postgresql.org/docs/current/static/runtime-config.html">Server Config</a>
+<a href="http://www.postgresql.org/docs/current/static/parallel-plans.html">Parallel Plans</a>
+<hr>
+
+<div class="navigation">
+  <a href="pg_hint_plan.html">pg_hint_plan</a>
+</div>
+
+<p class="footer">Copyright (c) 2012-2020, NIPPON TELEGRAPH AND TELEPHONE CORPORATION</p>
+</body>
+</html>
diff --git a/gpcontrib/pg_hint_plan/doc/style.css b/gpcontrib/pg_hint_plan/doc/style.css
new file mode 100644
index 0000000000..fb4820d828
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/doc/style.css
@@ -0,0 +1,110 @@
+body {
+	font-family:
+		Lucida Grande, Verdana, Arial, Helvetica,
+		'メイリオ',
+		'Meiryo',
+		'ヒラギノ角ゴ Pro W3',
+		'Hiragino Kaku Gothic Pro',
+		'Osaka',
+		'MS Pゴシック',
+		sans-serif;
+	color: #202020;
+}
+
+/* give the rule a bit of extra space (above and below), since its being used to divide
+   sections on some pages (project summary) */
+HR { margin: 5px 0px 5px 0px }
+
+
+h2, h3, h4, h5, h6 {
+    color: Black;
+    background: none;
+    padding-top: 0.5em;
+    padding-bottom: 0.17em;
+    border-bottom: 1px solid #aaaaaa;
+}
+H1 { font-size: x-large; font-family: Lucida Grande,verdana,arial,helvetica,sans-serif; }
+H2 { font-size: large; font-family: Lucida Grande,verdana,arial,helvetica,sans-serif; }
+H3 { padding-left: 1em; font-size: medium; font-family: Lucida Grande,verdana,arial,helvetica,sans-serif; }
+H4 { padding-left: 2em; font-size: small; font-family: Lucida Grande,verdana,arial,helvetica,sans-serif; }
+H5 { padding-left: 3em; font-size: x-small; font-family: Lucida Grande,verdana,arial,helvetica,sans-serif; }
+H6 { padding-left: 4em; font-size: xx-small; font-family: Lucida Grande,verdana,arial,helvetica,sans-serif; }
+
+pre {
+	font-family: courier,sans-serif;
+	background-color: #FBFBFD;
+	border: 1px dashed #7E7ECB;
+	color: black;
+	line-height: 1.1em; padding: 0.5em;
+	overflow: auto;
+}
+
+li {
+	line-height: 1.4em;
+}
+
+table {
+	background: #f9f9f9;
+	border: 1px solid #aaa;
+	border-collapse: collapse;
+}
+
+th, td {
+	border: 1px solid #aaa;
+	padding: 0.2em;
+}
+
+dt {
+	font-weight: 600;
+	margin-top: 1em;
+	margin-left: 1em;
+}
+dd {
+	margin-top: 0.5em;
+}
+
+thead th {
+	background: #f2f2f2;
+	text-align: center;
+}
+
+tbody th {
+	background: #f2f2f2;
+	text-align: left;
+}
+
+div.index {
+	float:right;
+	border:thin solid black;
+	background-color: white;
+	padding-top: 0.2em;
+	padding-bottom: 0.2em;
+	padding-left: 1em;
+	padding-right: 1em;
+	margin-left: 0.5em;
+}
+
+p.footer {
+	text-align: right;
+	font-size: small;
+}
+
+span.param {
+	color: #0000cd;
+}
+
+span.strong {
+	font-weight: bold;
+	text-decoration: underline;
+}
+
+div.tips{
+	font-size: small;
+	border: 1px solid #aaa;
+	background-color: #EFEFEF;
+	line-height: 1.1em; padding: 0.5em; margin: 0em 2em;
+}
+
+span.bold {
+	font-weight: bold;
+}
diff --git a/gpcontrib/pg_hint_plan/expected/.gitignore b/gpcontrib/pg_hint_plan/expected/.gitignore
new file mode 100644
index 0000000000..95c227304e
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/expected/.gitignore
@@ -0,0 +1,2 @@
+ut-fdw.out
+ut-W.out
\ No newline at end of file
diff --git a/gpcontrib/pg_hint_plan/expected/R_sample.out b/gpcontrib/pg_hint_plan/expected/R_sample.out
new file mode 100644
index 0000000000..bbad821560
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/expected/R_sample.out
@@ -0,0 +1,10 @@
+                                QUERY PLAN                                 
+---------------------------------------------------------------------------
+ Merge Join  (cost=xxx rows=100 width=29)
+   Merge Cond: (t1.c1 = t2.c1)
+   ->  Index Scan using t1_i1 on t1  (cost=xxx rows=1000 width=15)
+   ->  Sort  (cost=xxx rows=100 width=14)
+         Sort Key: t2.c1
+         ->  Seq Scan on t2  (cost=xxx rows=100 width=14)
+(6 rows)
+
diff --git a/gpcontrib/pg_hint_plan/expected/base_plan.out b/gpcontrib/pg_hint_plan/expected/base_plan.out
new file mode 100644
index 0000000000..9902f0d064
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/expected/base_plan.out
@@ -0,0 +1,77 @@
+SET search_path TO public;
+-- query type 1
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+              QUERY PLAN              
+--------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+-- query type 2
+EXPLAIN (COSTS false) SELECT * FROM t1, t4 WHERE t1.val < 10;
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Bitmap Heap Scan on t1
+         Recheck Cond: (val < 10)
+         ->  Bitmap Index Scan on t1_val
+               Index Cond: (val < 10)
+   ->  Materialize
+         ->  Seq Scan on t4
+(7 rows)
+
+-- query type 3
+EXPLAIN (COSTS false) SELECT * FROM t3, t4 WHERE t3.id = t4.id AND t4.ctid = '(1,1)';
+                 QUERY PLAN                  
+---------------------------------------------
+ Merge Join
+   Merge Cond: (t3.id = t4.id)
+   ->  Index Scan using t3_pkey on t3
+   ->  Sort
+         Sort Key: t4.id
+         ->  Seq Scan on t4
+               Filter: (ctid = '(1,1)'::tid)
+(7 rows)
+
+-- query type 4
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)';
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+(5 rows)
+
+-- query type 5
+EXPLAIN (COSTS false) SELECT * FROM t1, t3 WHERE t1.val = t3.val;
+           QUERY PLAN           
+--------------------------------
+ Hash Join
+   Hash Cond: (t1.val = t3.val)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Seq Scan on t3
+(5 rows)
+
+-- query type 6
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
+                    QUERY PLAN                    
+--------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t1.id = t4.id)
+         ->  Merge Join
+               Merge Cond: (t1.id = t2.id)
+               ->  Index Scan using t1_pkey on t1
+               ->  Index Scan using t2_pkey on t2
+         ->  Sort
+               Sort Key: t4.id
+               ->  Seq Scan on t4
+   ->  Index Scan using t3_pkey on t3
+         Index Cond: (id = t1.id)
+(12 rows)
+
diff --git a/gpcontrib/pg_hint_plan/expected/init.out b/gpcontrib/pg_hint_plan/expected/init.out
new file mode 100644
index 0000000000..0c282b91f5
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/expected/init.out
@@ -0,0 +1,212 @@
+SET search_path TO public;
+CREATE EXTENSION pg_hint_plan;
+CREATE SCHEMA s0;
+CREATE TABLE t1 (id int PRIMARY KEY, val int);
+CREATE TABLE t2 (id int PRIMARY KEY, val int);
+CREATE TABLE t3 (id int PRIMARY KEY, val int);
+CREATE TABLE t4 (id int PRIMARY KEY, val int);
+CREATE TABLE t5 (id int PRIMARY KEY, val int);
+CREATE TABLE p1 (id int PRIMARY KEY, val int);
+CREATE TABLE p1_c1 (LIKE p1 INCLUDING ALL, CHECK (id <= 100)) INHERITS(p1);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p1_c2 (LIKE p1 INCLUDING ALL, CHECK (id > 100 AND id <= 200)) INHERITS(p1);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p1_c3 (LIKE p1 INCLUDING ALL, CHECK (id > 200 AND id <= 300)) INHERITS(p1);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p1_c4 (LIKE p1 INCLUDING ALL, CHECK (id > 300)) INHERITS(p1);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p1_c1_c1 (LIKE p1 INCLUDING ALL, CHECK (id <= 50)) INHERITS(p1_c1);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p1_c1_c2 (LIKE p1 INCLUDING ALL, CHECK (id > 50 AND id <= 100)) INHERITS(p1_c1);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p1_c3_c1 (LIKE p1 INCLUDING ALL, CHECK (id > 200 AND id <= 250)) INHERITS(p1_c3);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p1_c3_c2 (LIKE p1 INCLUDING ALL, CHECK (id > 250 AND id <= 300)) INHERITS(p1_c3);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p2 (id int PRIMARY KEY, val text);
+CREATE INDEX p2_id_val_idx ON p2 (id, val);
+CREATE UNIQUE INDEX p2_val_idx ON p2 (val);
+CREATE INDEX p2_ununi_id_val_idx ON p2 (val);
+CREATE INDEX p2_val_idx_1 ON p2 USING hash (val);
+CREATE INDEX p2_val_id_idx ON p2 (val, id);
+CREATE INDEX p2_val_idx2 ON p2 (val COLLATE "C");
+CREATE INDEX p2_val_idx3 ON p2 (val varchar_ops);
+CREATE INDEX p2_val_idx4 ON p2 (val DESC NULLS LAST);
+CREATE INDEX p2_val_idx5 ON p2 (val NULLS FIRST);
+CREATE INDEX p2_expr ON p2 ((val < '120'));
+CREATE INDEX p2_expr2 ON p2 ((id * 2 < 120));
+CREATE INDEX p2_val_idx6 ON p2 (val) WHERE val >= '50' AND val < '51';
+CREATE INDEX p2_val_idx7 ON p2 (val) WHERE id < 120;
+CREATE TABLE p2_c1 (LIKE p2 INCLUDING ALL, CHECK (id <= 100)) INHERITS(p2);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p2_c2 (LIKE p2 INCLUDING ALL, CHECK (id > 100 AND id <= 200)) INHERITS(p2);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p2_c3 (LIKE p2 INCLUDING ALL, CHECK (id > 200 AND id <= 300)) INHERITS(p2);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p2_c4 (LIKE p2 INCLUDING ALL, CHECK (id > 300)) INHERITS(p2);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p2_c1_c1 (LIKE p2 INCLUDING ALL, CHECK (id <= 50)) INHERITS(p2_c1);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p2_c1_c2 (LIKE p2 INCLUDING ALL, CHECK (id > 50 AND id <= 100)) INHERITS(p2_c1);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p2_c3_c1 (LIKE p2 INCLUDING ALL, CHECK (id > 200 AND id <= 250)) INHERITS(p2_c3);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE p2_c3_c2 (LIKE p2 INCLUDING ALL, CHECK (id > 250 AND id <= 300)) INHERITS(p2_c3);
+NOTICE:  merging column "id" with inherited definition
+NOTICE:  merging column "val" with inherited definition
+CREATE TABLE s0.t1 (id int PRIMARY KEY, val int);
+INSERT INTO t1 SELECT i, i % 100 FROM (SELECT generate_series(1, 10000) i) t;
+INSERT INTO t2 SELECT i, i % 10 FROM (SELECT generate_series(1, 1000) i) t;
+INSERT INTO t3 SELECT i, i FROM (SELECT generate_series(1, 100) i) t;
+INSERT INTO t4 SELECT i, i FROM (SELECT generate_series(1, 10) i) t;
+INSERT INTO t5 SELECT i, i % 100 FROM (SELECT generate_series(1, 10000) i) t;
+INSERT INTO p1_c1_c1 SELECT i, i % 100 FROM (SELECT generate_series(1, 50) i) t;
+INSERT INTO p1_c1_c2 SELECT i, i % 100 FROM (SELECT generate_series(51, 100) i) t;
+INSERT INTO p1_c2 SELECT i, i % 100 FROM (SELECT generate_series(101, 200) i) t;
+INSERT INTO p1_c3_c1 SELECT i, i % 100 FROM (SELECT generate_series(201, 250) i) t;
+INSERT INTO p1_c3_c2 SELECT i, i % 100 FROM (SELECT generate_series(251, 300) i) t;
+INSERT INTO p1_c4 SELECT i, i % 100 FROM (SELECT generate_series(301, 400) i) t;
+INSERT INTO p2_c1_c1 SELECT i, i % 100 FROM (SELECT generate_series(1, 50) i) t;
+INSERT INTO p2_c1_c2 SELECT i, i % 100 FROM (SELECT generate_series(51, 100) i) t;
+INSERT INTO p2_c2 SELECT i, i % 100 FROM (SELECT generate_series(101, 200) i) t;
+INSERT INTO p2_c3_c1 SELECT i, i % 100 FROM (SELECT generate_series(201, 250) i) t;
+INSERT INTO p2_c3_c2 SELECT i, i % 100 FROM (SELECT generate_series(251, 300) i) t;
+INSERT INTO p2_c4 SELECT i, i % 100 FROM (SELECT generate_series(301, 400) i) t;
+CREATE INDEX t1_val ON t1 (val);
+CREATE INDEX t2_val ON t2 (val);
+CREATE INDEX t5_id1 ON t5 (id);
+CREATE INDEX t5_id2 ON t5 (id);
+CREATE INDEX t5_id3 ON t5 (id);
+CREATE INDEX t5_val ON t5 (val);
+DROP INDEX p2_c4_val_id_idx;
+CREATE INDEX p2_id2_val ON p2 (id, id, val);
+CREATE INDEX p2_c1_id2_val ON p2_c1 (id, id, val);
+CREATE INDEX p2_c2_id2_val ON p2_c2 (id, id, val);
+CREATE INDEX p2_val2_id ON p2 (val, id, val);
+CREATE INDEX t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ON t5 (id);
+CREATE INDEX p1_val1 ON p1 (val);
+CREATE INDEX p1_val2 ON p1 (val);
+CREATE INDEX p1_val3 ON p1 (val);
+CREATE INDEX p1_c1_val1 ON p1_c1 (val);
+CREATE INDEX p1_c1_val2 ON p1_c1 (val);
+CREATE INDEX p1_c1_val3 ON p1_c1 (val);
+CREATE INDEX p1_c1_c1_val1 ON p1_c1_c1 (val);
+CREATE INDEX p1_c1_c1_val2 ON p1_c1_c1 (val);
+CREATE INDEX p1_c1_c1_val3 ON p1_c1_c1 (val);
+CREATE INDEX p1_c1_c2_val1 ON p1_c1_c2 (val);
+CREATE INDEX p1_c1_c2_val2 ON p1_c1_c2 (val);
+CREATE INDEX p1_c1_c2_val3 ON p1_c1_c2 (val);
+CREATE INDEX p1_c2_val1 ON p1_c2 (val);
+CREATE INDEX p1_c2_val2 ON p1_c2 (val);
+CREATE INDEX p1_c2_val3 ON p1_c2 (val);
+CREATE INDEX p1_c3_val1 ON p1_c3 (val);
+CREATE INDEX p1_c3_val2 ON p1_c3 (val);
+CREATE INDEX p1_c3_val3 ON p1_c3 (val);
+CREATE INDEX p1_c3_c1_val1 ON p1_c3_c1 (val);
+CREATE INDEX p1_c3_c1_val2 ON p1_c3_c1 (val);
+CREATE INDEX p1_c3_c1_val3 ON p1_c3_c1 (val);
+CREATE INDEX p1_c3_c2_val1 ON p1_c3_c2 (val);
+CREATE INDEX p1_c3_c2_val2 ON p1_c3_c2 (val);
+CREATE INDEX p1_c3_c2_val3 ON p1_c3_c2 (val);
+CREATE INDEX p1_c4_val1 ON p1_c4 (val);
+CREATE INDEX p1_c4_val2 ON p1_c4 (val);
+CREATE INDEX p1_c4_val3 ON p1_c4 (val);
+ANALYZE t1;
+ANALYZE t2;
+ANALYZE t3;
+ANALYZE t4;
+ANALYZE t5;
+ANALYZE p1;
+ANALYZE p1_c1;
+ANALYZE p1_c2;
+ANALYZE p2;
+CREATE VIEW v1 AS SELECT id, val FROM t1;
+CREATE VIEW v2 AS SELECT t1.id t1_id, t1.val t1_val, t2.id t2_id, t2.val t2_val FROM t1, t2 WHERE t1.id = t2.id;
+CREATE VIEW v3 AS SELECT t_1.id t1_id, t_1.val t1_val, t_2.id t2_id, t_2.val t2_val FROM t1 t_1, t2 t_2 WHERE t_1.id = t_2.id;
+CREATE VIEW v4 AS SELECT v_2.t1_id, t_3.id FROM v2 v_2, t3 t_3 WHERE v_2.t1_id = t_3.id;
+/*
+ * The following GUC parameters need the setting of the default value to
+ * succeed in regression test.
+ */
+/* Fix auto-tunable parameters */
+ALTER SYSTEM SET effective_cache_size TO 16384;
+SELECT pg_reload_conf();
+ pg_reload_conf 
+----------------
+ t
+(1 row)
+
+SET effective_cache_size TO 16384;
+CREATE VIEW settings AS
+SELECT name, setting, category
+  FROM pg_settings
+ WHERE category LIKE 'Query Tuning%'
+    OR name = 'client_min_messages'
+ ORDER BY category, name;
+SELECT * FROM settings;
+              name              |  setting  |                    category                     
+--------------------------------+-----------+-------------------------------------------------
+ client_min_messages            | notice    | Client Connection Defaults / Statement Behavior
+ geqo                           | on        | Query Tuning / Genetic Query Optimizer
+ geqo_effort                    | 5         | Query Tuning / Genetic Query Optimizer
+ geqo_generations               | 0         | Query Tuning / Genetic Query Optimizer
+ geqo_pool_size                 | 0         | Query Tuning / Genetic Query Optimizer
+ geqo_seed                      | 0         | Query Tuning / Genetic Query Optimizer
+ geqo_selection_bias            | 2         | Query Tuning / Genetic Query Optimizer
+ geqo_threshold                 | 12        | Query Tuning / Genetic Query Optimizer
+ constraint_exclusion           | partition | Query Tuning / Other Planner Options
+ cursor_tuple_fraction          | 0.1       | Query Tuning / Other Planner Options
+ default_statistics_target      | 100       | Query Tuning / Other Planner Options
+ force_parallel_mode            | off       | Query Tuning / Other Planner Options
+ from_collapse_limit            | 8         | Query Tuning / Other Planner Options
+ jit                            | on        | Query Tuning / Other Planner Options
+ join_collapse_limit            | 8         | Query Tuning / Other Planner Options
+ plan_cache_mode                | auto      | Query Tuning / Other Planner Options
+ cpu_index_tuple_cost           | 0.005     | Query Tuning / Planner Cost Constants
+ cpu_operator_cost              | 0.0025    | Query Tuning / Planner Cost Constants
+ cpu_tuple_cost                 | 0.01      | Query Tuning / Planner Cost Constants
+ effective_cache_size           | 16384     | Query Tuning / Planner Cost Constants
+ jit_above_cost                 | 100000    | Query Tuning / Planner Cost Constants
+ jit_inline_above_cost          | 500000    | Query Tuning / Planner Cost Constants
+ jit_optimize_above_cost        | 500000    | Query Tuning / Planner Cost Constants
+ min_parallel_index_scan_size   | 64        | Query Tuning / Planner Cost Constants
+ min_parallel_table_scan_size   | 1024      | Query Tuning / Planner Cost Constants
+ parallel_setup_cost            | 1000      | Query Tuning / Planner Cost Constants
+ parallel_tuple_cost            | 0.1       | Query Tuning / Planner Cost Constants
+ random_page_cost               | 4         | Query Tuning / Planner Cost Constants
+ seq_page_cost                  | 1         | Query Tuning / Planner Cost Constants
+ enable_bitmapscan              | on        | Query Tuning / Planner Method Configuration
+ enable_gathermerge             | on        | Query Tuning / Planner Method Configuration
+ enable_hashagg                 | on        | Query Tuning / Planner Method Configuration
+ enable_hashjoin                | on        | Query Tuning / Planner Method Configuration
+ enable_indexonlyscan           | on        | Query Tuning / Planner Method Configuration
+ enable_indexscan               | on        | Query Tuning / Planner Method Configuration
+ enable_material                | on        | Query Tuning / Planner Method Configuration
+ enable_mergejoin               | on        | Query Tuning / Planner Method Configuration
+ enable_nestloop                | on        | Query Tuning / Planner Method Configuration
+ enable_parallel_append         | on        | Query Tuning / Planner Method Configuration
+ enable_parallel_hash           | on        | Query Tuning / Planner Method Configuration
+ enable_partition_pruning       | on        | Query Tuning / Planner Method Configuration
+ enable_partitionwise_aggregate | off       | Query Tuning / Planner Method Configuration
+ enable_partitionwise_join      | off       | Query Tuning / Planner Method Configuration
+ enable_seqscan                 | on        | Query Tuning / Planner Method Configuration
+ enable_sort                    | on        | Query Tuning / Planner Method Configuration
+ enable_tidscan                 | on        | Query Tuning / Planner Method Configuration
+(46 rows)
+
+ANALYZE;
diff --git a/gpcontrib/pg_hint_plan/expected/oldextversions.out b/gpcontrib/pg_hint_plan/expected/oldextversions.out
new file mode 100644
index 0000000000..f9d443c47c
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/expected/oldextversions.out
@@ -0,0 +1,94 @@
+--
+-- tests for upgrade paths
+--
+CREATE EXTENSION pg_hint_plan VERSION "1.3.0";
+\dx+ pg_hint_plan
+Objects in extension "pg_hint_plan"
+       Object description        
+---------------------------------
+ sequence hint_plan.hints_id_seq
+ table hint_plan.hints
+(2 rows)
+
+ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.1";
+\dx+ pg_hint_plan
+Objects in extension "pg_hint_plan"
+       Object description        
+---------------------------------
+ sequence hint_plan.hints_id_seq
+ table hint_plan.hints
+(2 rows)
+
+ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.2";
+\dx+ pg_hint_plan
+Objects in extension "pg_hint_plan"
+       Object description        
+---------------------------------
+ sequence hint_plan.hints_id_seq
+ table hint_plan.hints
+(2 rows)
+
+ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.3";
+\dx+ pg_hint_plan
+Objects in extension "pg_hint_plan"
+       Object description        
+---------------------------------
+ sequence hint_plan.hints_id_seq
+ table hint_plan.hints
+(2 rows)
+
+ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.4";
+\dx+ pg_hint_plan
+Objects in extension "pg_hint_plan"
+       Object description        
+---------------------------------
+ sequence hint_plan.hints_id_seq
+ table hint_plan.hints
+(2 rows)
+
+ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.5";
+\dx+ pg_hint_plan
+Objects in extension "pg_hint_plan"
+       Object description        
+---------------------------------
+ sequence hint_plan.hints_id_seq
+ table hint_plan.hints
+(2 rows)
+
+ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.6";
+\dx+ pg_hint_plan
+Objects in extension "pg_hint_plan"
+       Object description        
+---------------------------------
+ sequence hint_plan.hints_id_seq
+ table hint_plan.hints
+(2 rows)
+
+ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.7";
+\dx+ pg_hint_plan
+Objects in extension "pg_hint_plan"
+       Object description        
+---------------------------------
+ sequence hint_plan.hints_id_seq
+ table hint_plan.hints
+(2 rows)
+
+ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.8";
+\dx+ pg_hint_plan
+Objects in extension "pg_hint_plan"
+       Object description        
+---------------------------------
+ sequence hint_plan.hints_id_seq
+ table hint_plan.hints
+(2 rows)
+
+ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.9";
+\dx+ pg_hint_plan
+Objects in extension "pg_hint_plan"
+       Object description        
+---------------------------------
+ sequence hint_plan.hints_id_seq
+ table hint_plan.hints
+(2 rows)
+
+DROP EXTENSION pg_hint_plan;
diff --git a/gpcontrib/pg_hint_plan/expected/pg_hint_plan.out b/gpcontrib/pg_hint_plan/expected/pg_hint_plan.out
new file mode 100644
index 0000000000..538e767d7e
--- /dev/null
+++ b/gpcontrib/pg_hint_plan/expected/pg_hint_plan.out
@@ -0,0 +1,9166 @@
+SET search_path TO public;
+SET client_min_messages TO log;
+\set SHOW_CONTEXT always
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+              QUERY PLAN              
+--------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.val = t2.val;
+           QUERY PLAN           
+--------------------------------
+ Hash Join
+   Hash Cond: (t2.val = t1.val)
+   ->  Seq Scan on t2
+   ->  Hash
+         ->  Seq Scan on t1
+(5 rows)
+
+LOAD 'pg_hint_plan';
+SET pg_hint_plan.debug_print TO on;
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+              QUERY PLAN              
+--------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.val = t2.val;
+           QUERY PLAN           
+--------------------------------
+ Hash Join
+   Hash Cond: (t2.val = t1.val)
+   ->  Seq Scan on t2
+   ->  Hash
+         ->  Seq Scan on t1
+(5 rows)
+
+/*+ Test (t1 t2) */
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+INFO:  pg_hint_plan: hint syntax error at or near "Test (t1 t2) "
+DETAIL:  Unrecognized hint keyword "Test".
+              QUERY PLAN              
+--------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+SET pg_hint_plan.enable_hint TO off;
+/*+ Test (t1 t2) */
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+              QUERY PLAN              
+--------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+SET pg_hint_plan.enable_hint TO on;
+/*Set(enable_indexscan off)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+              QUERY PLAN              
+--------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+--+Set(enable_indexscan off)
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+              QUERY PLAN              
+--------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+/*+Set(enable_indexscan off) /* nest comment */ */
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+INFO:  pg_hint_plan: hint syntax error at or near "/* nest comment */ */
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;"
+DETAIL:  Nested block comments are not supported.
+              QUERY PLAN              
+--------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+/*+Set(enable_indexscan off)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+Set(enable_indexscan off)
+not used hint:
+duplication hint:
+error hint:
+
+          QUERY PLAN          
+------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Seq Scan on t2
+(5 rows)
+
+EXPLAIN (COSTS false) /*+Set(enable_indexscan off)*/
+ SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+Set(enable_indexscan off)
+not used hint:
+duplication hint:
+error hint:
+
+          QUERY PLAN          
+------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Seq Scan on t2
+(5 rows)
+
+/*+ Set(enable_indexscan off) Set(enable_hashjoin off) */
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+Set(enable_hashjoin off)
+Set(enable_indexscan off)
+not used hint:
+duplication hint:
+error hint:
+
+          QUERY PLAN           
+-------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Sort
+         Sort Key: t1.id
+         ->  Seq Scan on t1
+   ->  Sort
+         Sort Key: t2.id
+         ->  Seq Scan on t2
+(8 rows)
+
+/*+ 	 Set 	 ( 	 enable_indexscan 	 off 	 ) 	 */
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+Set(enable_indexscan off)
+not used hint:
+duplication hint:
+error hint:
+
+          QUERY PLAN          
+------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Seq Scan on t2
+(5 rows)
+
+/*+ 	 
+	 	Set 	 
+	 	( 	 
+	 	enable_indexscan 	 
+	 	off 	 
+	 	) 	 
+	 	*/	 	
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+Set(enable_indexscan off)
+not used hint:
+duplication hint:
+error hint:
+
+          QUERY PLAN          
+------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Seq Scan on t2
+(5 rows)
+
+/*+ Set(enable_indexscan off)Set(enable_nestloop off)Set(enable_mergejoin off)	 	
+	 	Set(enable_seqscan off)
+	 	*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+Set(enable_indexscan off)
+Set(enable_mergejoin off)
+Set(enable_nestloop off)
+Set(enable_seqscan off)
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                 
+--------------------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Hash
+         ->  Index Scan using t2_pkey on t2
+(5 rows)
+
+/*+Set(work_mem "1M")*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+INFO:  invalid value for parameter "work_mem": "1M"
+HINT:  Valid units for this parameter are "B", "kB", "MB", "GB", and "TB".
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Set(work_mem 1M)
+
+              QUERY PLAN              
+--------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+/*+Set(work_mem "1MB")*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+Set(work_mem 1MB)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN              
+--------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+/*+Set(work_mem TO "1MB")*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+INFO:  pg_hint_plan: hint syntax error at or near "Set(work_mem TO "1MB")"
+DETAIL:  Set hint requires name and value of GUC parameter.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Set(work_mem TO 1MB)
+
+              QUERY PLAN              
+--------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+/*+SeqScan() */ SELECT 1;
+INFO:  pg_hint_plan: hint syntax error at or near " "
+DETAIL:  SeqScan hint requires a relation.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+SeqScan()
+
+ ?column? 
+----------
+        1
+(1 row)
+
+/*+SeqScan(t1 t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+INFO:  pg_hint_plan: hint syntax error at or near ""
+DETAIL:  SeqScan hint accepts only one relation.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+SeqScan(t1 t2)
+
+              QUERY PLAN              
+--------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+/*+SeqScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+          QUERY PLAN          
+------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Seq Scan on t2
+(5 rows)
+
+/*+SeqScan(t1)IndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+IndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                 
+--------------------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Index Scan using t2_pkey on t2
+(5 rows)
+
+/*+BitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Seq Scan on t1
+   ->  Bitmap Heap Scan on t2
+         Recheck Cond: (id = t1.id)
+         ->  Bitmap Index Scan on t2_pkey
+               Index Cond: (id = t1.id)
+(6 rows)
+
+/*+BitmapScan(t2)NoSeqScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+NoSeqScan(t1)
+BitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Index Scan using t1_pkey on t1
+   ->  Bitmap Heap Scan on t2
+         Recheck Cond: (id = t1.id)
+         ->  Bitmap Index Scan on t2_pkey
+               Index Cond: (id = t1.id)
+(6 rows)
+
+/*+NoIndexScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+NoIndexScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+          QUERY PLAN          
+------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Seq Scan on t2
+(5 rows)
+
+/*+NoBitmapScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t4 WHERE t1.val < 10;
+LOG:  pg_hint_plan:
+used hint:
+NoBitmapScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+         QUERY PLAN         
+----------------------------
+ Nested Loop
+   ->  Seq Scan on t1
+         Filter: (val < 10)
+   ->  Materialize
+         ->  Seq Scan on t4
+(5 rows)
+
+/*+TidScan(t4)*/
+EXPLAIN (COSTS false) SELECT * FROM t3, t4 WHERE t3.id = t4.id AND t4.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(t4)
+not used hint:
+duplication hint:
+error hint:
+
+                  QUERY PLAN                   
+-----------------------------------------------
+ Merge Join
+   Merge Cond: (t3.id = t4.id)
+   ->  Index Scan using t3_pkey on t3
+   ->  Sort
+         Sort Key: t4.id
+         ->  Tid Scan on t4
+               TID Cond: (ctid = '(1,1)'::tid)
+(7 rows)
+
+/*+NoTidScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoTidScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN               
+---------------------------------------
+ Nested Loop
+   ->  Seq Scan on t1
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+(5 rows)
+
+/*+ NestLoop() */ SELECT 1;
+INFO:  pg_hint_plan: hint syntax error at or near " "
+DETAIL:  NestLoop hint requires at least two relations.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+NestLoop()
+
+ ?column? 
+----------
+        1
+(1 row)
+
+/*+ NestLoop(x) */ SELECT 1;
+INFO:  pg_hint_plan: hint syntax error at or near " "
+DETAIL:  NestLoop hint requires at least two relations.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+NestLoop(x)
+
+ ?column? 
+----------
+        1
+(1 row)
+
+/*+HashJoin(t1 t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+HashJoin(t1 t2)
+not used hint:
+duplication hint:
+error hint:
+
+          QUERY PLAN          
+------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Seq Scan on t2
+(5 rows)
+
+/*+NestLoop(t1 t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+NestLoop(t1 t2)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN              
+--------------------------------------
+ Nested Loop
+   ->  Seq Scan on t2
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+(4 rows)
+
+/*+NoMergeJoin(t1 t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+NoMergeJoin(t1 t2)
+not used hint:
+duplication hint:
+error hint:
+
+          QUERY PLAN          
+------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Seq Scan on t2
+(5 rows)
+
+/*+MergeJoin(t1 t3)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t3 WHERE t1.val = t3.val;
+LOG:  pg_hint_plan:
+used hint:
+MergeJoin(t1 t3)
+not used hint:
+duplication hint:
+error hint:
+
+             QUERY PLAN              
+-------------------------------------
+ Merge Join
+   Merge Cond: (t1.val = t3.val)
+   ->  Index Scan using t1_val on t1
+   ->  Sort
+         Sort Key: t3.val
+         ->  Seq Scan on t3
+(6 rows)
+
+/*+NestLoop(t1 t3)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t3 WHERE t1.val = t3.val;
+LOG:  pg_hint_plan:
+used hint:
+NestLoop(t1 t3)
+not used hint:
+duplication hint:
+error hint:
+
+             QUERY PLAN              
+-------------------------------------
+ Nested Loop
+   ->  Seq Scan on t3
+   ->  Index Scan using t1_val on t1
+         Index Cond: (val = t3.val)
+(4 rows)
+
+/*+NoHashJoin(t1 t3)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t3 WHERE t1.val = t3.val;
+LOG:  pg_hint_plan:
+used hint:
+NoHashJoin(t1 t3)
+not used hint:
+duplication hint:
+error hint:
+
+             QUERY PLAN              
+-------------------------------------
+ Nested Loop
+   ->  Seq Scan on t3
+   ->  Index Scan using t1_val on t1
+         Index Cond: (val = t3.val)
+(4 rows)
+
+/*+MergeJoin(t4 t1 t2 t3)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
+LOG:  pg_hint_plan:
+used hint:
+MergeJoin(t1 t2 t3 t4)
+not used hint:
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t3.id)
+   ->  Merge Join
+         Merge Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+         ->  Index Scan using t2_pkey on t2
+   ->  Materialize
+         ->  Merge Join
+               Merge Cond: (t3.id = t4.id)
+               ->  Index Scan using t3_pkey on t3
+               ->  Sort
+                     Sort Key: t4.id
+                     ->  Seq Scan on t4
+(13 rows)
+
+/*+HashJoin(t3 t4 t1 t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
+LOG:  pg_hint_plan:
+used hint:
+HashJoin(t1 t2 t3 t4)
+not used hint:
+duplication hint:
+error hint:
+
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Hash Join
+   Hash Cond: (t3.id = t1.id)
+   ->  Seq Scan on t3
+   ->  Hash
+         ->  Merge Join
+               Merge Cond: (t1.id = t4.id)
+               ->  Merge Join
+                     Merge Cond: (t1.id = t2.id)
+                     ->  Index Scan using t1_pkey on t1
+                     ->  Index Scan using t2_pkey on t2
+               ->  Sort
+                     Sort Key: t4.id
+                     ->  Seq Scan on t4
+(13 rows)
+
+/*+NestLoop(t2 t3 t4 t1) IndexScan(t3)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t3)
+NestLoop(t1 t2 t3 t4)
+not used hint:
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t1.id = t4.id)
+         ->  Merge Join
+               Merge Cond: (t1.id = t2.id)
+               ->  Index Scan using t1_pkey on t1
+               ->  Index Scan using t2_pkey on t2
+         ->  Sort
+               Sort Key: t4.id
+               ->  Seq Scan on t4
+   ->  Index Scan using t3_pkey on t3
+         Index Cond: (id = t1.id)
+(12 rows)
+
+/*+NoNestLoop(t4 t1 t3 t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
+LOG:  pg_hint_plan:
+used hint:
+NoNestLoop(t1 t2 t3 t4)
+not used hint:
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t3.id)
+   ->  Merge Join
+         Merge Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+         ->  Index Scan using t2_pkey on t2
+   ->  Materialize
+         ->  Merge Join
+               Merge Cond: (t3.id = t4.id)
+               ->  Index Scan using t3_pkey on t3
+               ->  Sort
+                     Sort Key: t4.id
+                     ->  Seq Scan on t4
+(13 rows)
+
+/*+Leading( */
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
+INFO:  pg_hint_plan: hint syntax error at or near ""
+DETAIL:  Closing parenthesis is necessary.
+                    QUERY PLAN                    
+--------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t1.id = t4.id)
+         ->  Merge Join
+               Merge Cond: (t1.id = t2.id)
+               ->  Index Scan using t1_pkey on t1
+               ->  Index Scan using t2_pkey on t2
+         ->  Sort
+               Sort Key: t4.id
+               ->  Seq Scan on t4
+   ->  Index Scan using t3_pkey on t3
+         Index Cond: (id = t1.id)
+(12 rows)
+
+/*+Leading( )*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
+INFO:  pg_hint_plan: hint syntax error at or near "Leading( )"
+DETAIL:  Leading hint requires at least two relations.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Leading()
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t1.id = t4.id)
+         ->  Merge Join
+               Merge Cond: (t1.id = t2.id)
+               ->  Index Scan using t1_pkey on t1
+               ->  Index Scan using t2_pkey on t2
+         ->  Sort
+               Sort Key: t4.id
+               ->  Seq Scan on t4
+   ->  Index Scan using t3_pkey on t3
+         Index Cond: (id = t1.id)
+(12 rows)
+
+/*+Leading( t3 )*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
+INFO:  pg_hint_plan: hint syntax error at or near "Leading( t3 )"
+DETAIL:  Leading hint requires at least two relations.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Leading(t3)
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t1.id = t4.id)
+         ->  Merge Join
+               Merge Cond: (t1.id = t2.id)
+               ->  Index Scan using t1_pkey on t1
+               ->  Index Scan using t2_pkey on t2
+         ->  Sort
+               Sort Key: t4.id
+               ->  Seq Scan on t4
+   ->  Index Scan using t3_pkey on t3
+         Index Cond: (id = t1.id)
+(12 rows)
+
+/*+Leading( t3 t4 )*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
+LOG:  pg_hint_plan:
+used hint:
+Leading(t3 t4)
+not used hint:
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Nested Loop
+   ->  Nested Loop
+         ->  Merge Join
+               Merge Cond: (t3.id = t4.id)
+               ->  Index Scan using t3_pkey on t3
+               ->  Sort
+                     Sort Key: t4.id
+                     ->  Seq Scan on t4
+         ->  Index Scan using t2_pkey on t2
+               Index Cond: (id = t3.id)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+(12 rows)
+
+/*+Leading(t3 t4 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
+LOG:  pg_hint_plan:
+used hint:
+Leading(t3 t4 t1)
+not used hint:
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t3.id = t1.id)
+         ->  Merge Join
+               Merge Cond: (t3.id = t4.id)
+               ->  Index Scan using t3_pkey on t3
+               ->  Sort
+                     Sort Key: t4.id
+                     ->  Seq Scan on t4
+         ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+(12 rows)
+
+/*+Leading(t3 t4 t1 t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
+LOG:  pg_hint_plan:
+used hint:
+Leading(t3 t4 t1 t2)
+not used hint:
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t3.id = t1.id)
+         ->  Merge Join
+               Merge Cond: (t3.id = t4.id)
+               ->  Index Scan using t3_pkey on t3
+               ->  Sort
+                     Sort Key: t4.id
+                     ->  Seq Scan on t4
+         ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+(12 rows)
+
+/*+Leading(t3 t4 t1 t2 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
+INFO:  pg_hint_plan: hint syntax error at or near "Leading(t3 t4 t1 t2 t1)"
+DETAIL:  Relation name "t1" is duplicated.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Leading(t3 t4 t1 t2 t1)
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t1.id = t4.id)
+         ->  Merge Join
+               Merge Cond: (t1.id = t2.id)
+               ->  Index Scan using t1_pkey on t1
+               ->  Index Scan using t2_pkey on t2
+         ->  Sort
+               Sort Key: t4.id
+               ->  Seq Scan on t4
+   ->  Index Scan using t3_pkey on t3
+         Index Cond: (id = t1.id)
+(12 rows)
+
+/*+Leading(t3 t4 t4)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
+INFO:  pg_hint_plan: hint syntax error at or near "Leading(t3 t4 t4)"
+DETAIL:  Relation name "t4" is duplicated.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Leading(t3 t4 t4)
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t1.id = t4.id)
+         ->  Merge Join
+               Merge Cond: (t1.id = t2.id)
+               ->  Index Scan using t1_pkey on t1
+               ->  Index Scan using t2_pkey on t2
+         ->  Sort
+               Sort Key: t4.id
+               ->  Seq Scan on t4
+   ->  Index Scan using t3_pkey on t3
+         Index Cond: (id = t1.id)
+(12 rows)
+
+EXPLAIN (COSTS false) SELECT * FROM t1, (VALUES(1,1),(2,2),(3,3)) AS t2(id,val) WHERE t1.id = t2.id;
+                  QUERY PLAN                   
+-----------------------------------------------
+ Nested Loop
+   ->  Values Scan on "*VALUES*"
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = "*VALUES*".column1)
+(4 rows)
+
+/*+HashJoin(t1 t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, (VALUES(1,1),(2,2),(3,3)) AS t2(id,val) WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+HashJoin(t1 t2)
+duplication hint:
+error hint:
+
+                  QUERY PLAN                   
+-----------------------------------------------
+ Nested Loop
+   ->  Values Scan on "*VALUES*"
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = "*VALUES*".column1)
+(4 rows)
+
+/*+HashJoin(t1 *VALUES*)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, (VALUES(1,1),(2,2),(3,3)) AS t2(id,val) WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+HashJoin(*VALUES* t1)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                 
+-------------------------------------------
+ Hash Join
+   Hash Cond: (t1.id = "*VALUES*".column1)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Values Scan on "*VALUES*"
+(5 rows)
+
+/*+HashJoin(t1 *VALUES*) IndexScan(t1) IndexScan(*VALUES*)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, (VALUES(1,1),(2,2),(3,3)) AS t2(id,val) WHERE t1.id = t2.id;
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+HashJoin(*VALUES* t1)
+not used hint:
+IndexScan(*VALUES*)
+duplication hint:
+error hint:
+
+                QUERY PLAN                 
+-------------------------------------------
+ Hash Join
+   Hash Cond: (t1.id = "*VALUES*".column1)
+   ->  Index Scan using t1_pkey on t1
+   ->  Hash
+         ->  Values Scan on "*VALUES*"
+(5 rows)
+
+-- single table scan hint test
+EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10);
+                               QUERY PLAN                               
+------------------------------------------------------------------------
+ Index Only Scan using t1_pkey on t1
+   Index Cond: (id = $3)
+   InitPlan 2 (returns $1)
+     ->  Result
+           InitPlan 1 (returns $0)
+             ->  Limit
+                   ->  Index Only Scan Backward using t1_pkey on t1 v_1
+                         Index Cond: ((id IS NOT NULL) AND (id < 10))
+   InitPlan 4 (returns $3)
+     ->  Result
+           InitPlan 3 (returns $2)
+             ->  Limit
+                   ->  Index Only Scan Backward using t1_pkey on t1 v_2
+                         Index Cond: ((id IS NOT NULL) AND (id < 10))
+(14 rows)
+
+/*+BitmapScan(v_1)*/
+EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10);
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(v_1)
+not used hint:
+duplication hint:
+error hint:
+
+                               QUERY PLAN                               
+------------------------------------------------------------------------
+ Index Only Scan using t1_pkey on t1
+   Index Cond: (id = $3)
+   InitPlan 1 (returns $1)
+     ->  Aggregate
+           ->  Bitmap Heap Scan on t1 v_1
+                 Recheck Cond: (id < 10)
+                 ->  Bitmap Index Scan on t1_pkey
+                       Index Cond: (id < 10)
+   InitPlan 3 (returns $3)
+     ->  Result
+           InitPlan 2 (returns $2)
+             ->  Limit
+                   ->  Index Only Scan Backward using t1_pkey on t1 v_2
+                         Index Cond: ((id IS NOT NULL) AND (id < 10))
+(14 rows)
+
+/*+BitmapScan(v_2)*/
+EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10);
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(v_2)
+not used hint:
+duplication hint:
+error hint:
+
+                               QUERY PLAN                               
+------------------------------------------------------------------------
+ Index Only Scan using t1_pkey on t1
+   Index Cond: (id = $3)
+   InitPlan 2 (returns $1)
+     ->  Result
+           InitPlan 1 (returns $0)
+             ->  Limit
+                   ->  Index Only Scan Backward using t1_pkey on t1 v_1
+                         Index Cond: ((id IS NOT NULL) AND (id < 10))
+   InitPlan 3 (returns $3)
+     ->  Aggregate
+           ->  Bitmap Heap Scan on t1 v_2
+                 Recheck Cond: (id < 10)
+                 ->  Bitmap Index Scan on t1_pkey
+                       Index Cond: (id < 10)
+(14 rows)
+
+/*+BitmapScan(t1)*/
+EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10);
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+                               QUERY PLAN                               
+------------------------------------------------------------------------
+ Bitmap Heap Scan on t1
+   Recheck Cond: (id = $3)
+   InitPlan 2 (returns $1)
+     ->  Result
+           InitPlan 1 (returns $0)
+             ->  Limit
+                   ->  Index Only Scan Backward using t1_pkey on t1 v_1
+                         Index Cond: ((id IS NOT NULL) AND (id < 10))
+   InitPlan 4 (returns $3)
+     ->  Result
+           InitPlan 3 (returns $2)
+             ->  Limit
+                   ->  Index Only Scan Backward using t1_pkey on t1 v_2
+                         Index Cond: ((id IS NOT NULL) AND (id < 10))
+   ->  Bitmap Index Scan on t1_pkey
+         Index Cond: (id = $3)
+(16 rows)
+
+/*+BitmapScan(v_1)BitmapScan(v_2)*/
+EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10);
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(v_1)
+BitmapScan(v_2)
+not used hint:
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Index Only Scan using t1_pkey on t1
+   Index Cond: (id = $3)
+   InitPlan 1 (returns $1)
+     ->  Aggregate
+           ->  Bitmap Heap Scan on t1 v_1
+                 Recheck Cond: (id < 10)
+                 ->  Bitmap Index Scan on t1_pkey
+                       Index Cond: (id < 10)
+   InitPlan 2 (returns $3)
+     ->  Aggregate
+           ->  Bitmap Heap Scan on t1 v_2
+                 Recheck Cond: (id < 10)
+                 ->  Bitmap Index Scan on t1_pkey
+                       Index Cond: (id < 10)
+(14 rows)
+
+/*+BitmapScan(v_1)BitmapScan(t1)*/
+EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10);
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+BitmapScan(v_1)
+not used hint:
+duplication hint:
+error hint:
+
+                               QUERY PLAN                               
+------------------------------------------------------------------------
+ Bitmap Heap Scan on t1
+   Recheck Cond: (id = $3)
+   InitPlan 1 (returns $1)
+     ->  Aggregate
+           ->  Bitmap Heap Scan on t1 v_1
+                 Recheck Cond: (id < 10)
+                 ->  Bitmap Index Scan on t1_pkey
+                       Index Cond: (id < 10)
+   InitPlan 3 (returns $3)
+     ->  Result
+           InitPlan 2 (returns $2)
+             ->  Limit
+                   ->  Index Only Scan Backward using t1_pkey on t1 v_2
+                         Index Cond: ((id IS NOT NULL) AND (id < 10))
+   ->  Bitmap Index Scan on t1_pkey
+         Index Cond: (id = $3)
+(16 rows)
+
+/*+BitmapScan(v_2)BitmapScan(t1)*/
+EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10);
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+BitmapScan(v_2)
+not used hint:
+duplication hint:
+error hint:
+
+                               QUERY PLAN                               
+------------------------------------------------------------------------
+ Bitmap Heap Scan on t1
+   Recheck Cond: (id = $3)
+   InitPlan 2 (returns $1)
+     ->  Result
+           InitPlan 1 (returns $0)
+             ->  Limit
+                   ->  Index Only Scan Backward using t1_pkey on t1 v_1
+                         Index Cond: ((id IS NOT NULL) AND (id < 10))
+   InitPlan 3 (returns $3)
+     ->  Aggregate
+           ->  Bitmap Heap Scan on t1 v_2
+                 Recheck Cond: (id < 10)
+                 ->  Bitmap Index Scan on t1_pkey
+                       Index Cond: (id < 10)
+   ->  Bitmap Index Scan on t1_pkey
+         Index Cond: (id = $3)
+(16 rows)
+
+/*+BitmapScan(v_1)BitmapScan(v_2)BitmapScan(t1)*/
+EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10);
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+BitmapScan(v_1)
+BitmapScan(v_2)
+not used hint:
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Bitmap Heap Scan on t1
+   Recheck Cond: (id = $3)
+   InitPlan 1 (returns $1)
+     ->  Aggregate
+           ->  Bitmap Heap Scan on t1 v_1
+                 Recheck Cond: (id < 10)
+                 ->  Bitmap Index Scan on t1_pkey
+                       Index Cond: (id < 10)
+   InitPlan 2 (returns $3)
+     ->  Aggregate
+           ->  Bitmap Heap Scan on t1 v_2
+                 Recheck Cond: (id < 10)
+                 ->  Bitmap Index Scan on t1_pkey
+                       Index Cond: (id < 10)
+   ->  Bitmap Index Scan on t1_pkey
+         Index Cond: (id = $3)
+(16 rows)
+
+-- full scan hint pattern test
+EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)';
+            QUERY PLAN             
+-----------------------------------
+ Tid Scan on t1
+   TID Cond: (ctid = '(1,1)'::tid)
+   Filter: (id < 10)
+(3 rows)
+
+/*+SeqScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+                   QUERY PLAN                    
+-------------------------------------------------
+ Seq Scan on t1
+   Filter: ((id < 10) AND (ctid = '(1,1)'::tid))
+(2 rows)
+
+/*+IndexScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+           QUERY PLAN            
+---------------------------------
+ Index Scan using t1_pkey on t1
+   Index Cond: (id < 10)
+   Filter: (ctid = '(1,1)'::tid)
+(3 rows)
+
+/*+BitmapScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+             QUERY PLAN             
+------------------------------------
+ Bitmap Heap Scan on t1
+   Recheck Cond: (id < 10)
+   Filter: (ctid = '(1,1)'::tid)
+   ->  Bitmap Index Scan on t1_pkey
+         Index Cond: (id < 10)
+(5 rows)
+
+/*+TidScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+            QUERY PLAN             
+-----------------------------------
+ Tid Scan on t1
+   TID Cond: (ctid = '(1,1)'::tid)
+   Filter: (id < 10)
+(3 rows)
+
+/*+NoSeqScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoSeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+            QUERY PLAN             
+-----------------------------------
+ Tid Scan on t1
+   TID Cond: (ctid = '(1,1)'::tid)
+   Filter: (id < 10)
+(3 rows)
+
+/*+NoIndexScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoIndexScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+            QUERY PLAN             
+-----------------------------------
+ Tid Scan on t1
+   TID Cond: (ctid = '(1,1)'::tid)
+   Filter: (id < 10)
+(3 rows)
+
+/*+NoBitmapScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoBitmapScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+            QUERY PLAN             
+-----------------------------------
+ Tid Scan on t1
+   TID Cond: (ctid = '(1,1)'::tid)
+   Filter: (id < 10)
+(3 rows)
+
+/*+NoTidScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoTidScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+           QUERY PLAN            
+---------------------------------
+ Index Scan using t1_pkey on t1
+   Index Cond: (id < 10)
+   Filter: (ctid = '(1,1)'::tid)
+(3 rows)
+
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+SeqScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Seq Scan on t1
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+SeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Seq Scan on t2
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+SeqScan(t1) SeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+SeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN               
+---------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Seq Scan on t1
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Seq Scan on t2
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+SeqScan(t1) IndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+IndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN               
+---------------------------------------
+ Nested Loop
+   ->  Seq Scan on t1
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+SeqScan(t1) BitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+BitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Seq Scan on t1
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t2
+         Recheck Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t2_pkey
+               Index Cond: (id = t1.id)
+(8 rows)
+
+/*+SeqScan(t1) TidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+TidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Seq Scan on t1
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+SeqScan(t1) NoSeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+NoSeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Seq Scan on t1
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+SeqScan(t1) NoIndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+NoIndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Seq Scan on t1
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+SeqScan(t1) NoBitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+NoBitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Seq Scan on t1
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+SeqScan(t1) NoTidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+NoTidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN               
+---------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Seq Scan on t1
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Seq Scan on t2
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+IndexScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+IndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+IndexScan(t1) SeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+SeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN               
+---------------------------------------
+ Nested Loop
+   ->  Seq Scan on t2
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+IndexScan(t1) IndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+IndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN               
+---------------------------------------
+ Nested Loop
+   ->  Index Scan using t2_pkey on t2
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+IndexScan(t1) BitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+BitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Index Scan using t1_pkey on t1
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t2
+         Recheck Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t2_pkey
+               Index Cond: (id = t1.id)
+(8 rows)
+
+/*+IndexScan(t1) TidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+TidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+IndexScan(t1) NoSeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+NoSeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+IndexScan(t1) NoIndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+NoIndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+IndexScan(t1) NoBitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+NoBitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+IndexScan(t1) NoTidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+NoTidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN               
+---------------------------------------
+ Nested Loop
+   ->  Seq Scan on t2
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+BitmapScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t1
+         Recheck Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t1_pkey
+               Index Cond: (id = t2.id)
+(8 rows)
+
+/*+BitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t2
+         Recheck Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t2_pkey
+               Index Cond: (id = t1.id)
+(8 rows)
+
+/*+BitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t2
+         Recheck Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t2_pkey
+               Index Cond: (id = t1.id)
+(8 rows)
+
+/*+BitmapScan(t1) SeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+SeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Seq Scan on t2
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t1
+         Recheck Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t1_pkey
+               Index Cond: (id = t2.id)
+(8 rows)
+
+/*+BitmapScan(t1) IndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+IndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Index Scan using t2_pkey on t2
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t1
+         Recheck Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t1_pkey
+               Index Cond: (id = t2.id)
+(8 rows)
+
+/*+BitmapScan(t1) BitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+BitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Index Scan using t2_pkey on t2
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t1
+         Recheck Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t1_pkey
+               Index Cond: (id = t2.id)
+(8 rows)
+
+/*+BitmapScan(t1) TidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+TidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t1
+         Recheck Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t1_pkey
+               Index Cond: (id = t2.id)
+(8 rows)
+
+/*+BitmapScan(t1) NoSeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+NoSeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t1
+         Recheck Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t1_pkey
+               Index Cond: (id = t2.id)
+(8 rows)
+
+/*+BitmapScan(t1) NoIndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+NoIndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t1
+         Recheck Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t1_pkey
+               Index Cond: (id = t2.id)
+(8 rows)
+
+/*+BitmapScan(t1) NoBitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+NoBitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t1
+         Recheck Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t1_pkey
+               Index Cond: (id = t2.id)
+(8 rows)
+
+/*+BitmapScan(t1) NoTidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+NoTidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Seq Scan on t2
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t1
+         Recheck Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t1_pkey
+               Index Cond: (id = t2.id)
+(8 rows)
+
+/*+TidScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+TidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+TidScan(t1) SeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(t1)
+SeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Seq Scan on t2
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+TidScan(t1) IndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(t1)
+IndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+TidScan(t1) BitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(t1)
+BitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t2
+         Recheck Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t2_pkey
+               Index Cond: (id = t1.id)
+(8 rows)
+
+/*+TidScan(t1) TidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(t1)
+TidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+TidScan(t1) NoSeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(t1)
+NoSeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+TidScan(t1) NoIndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(t1)
+NoIndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+TidScan(t1) NoBitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(t1)
+NoBitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+TidScan(t1) NoTidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(t1)
+NoTidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoSeqScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoSeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoSeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoSeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoSeqScan(t1) SeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoSeqScan(t1)
+SeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Seq Scan on t2
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoSeqScan(t1) IndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoSeqScan(t1)
+IndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoSeqScan(t1) BitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoSeqScan(t1)
+BitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t2
+         Recheck Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t2_pkey
+               Index Cond: (id = t1.id)
+(8 rows)
+
+/*+NoSeqScan(t1) TidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoSeqScan(t1)
+TidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoSeqScan(t1) NoSeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoSeqScan(t1)
+NoSeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoSeqScan(t1) NoIndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoSeqScan(t1)
+NoIndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoSeqScan(t1) NoBitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoSeqScan(t1)
+NoBitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoSeqScan(t1) NoTidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoSeqScan(t1)
+NoTidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoIndexScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoIndexScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoIndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoIndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoIndexScan(t1) SeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoIndexScan(t1)
+SeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Seq Scan on t2
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoIndexScan(t1) IndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoIndexScan(t1)
+IndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoIndexScan(t1) BitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoIndexScan(t1)
+BitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t2
+         Recheck Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t2_pkey
+               Index Cond: (id = t1.id)
+(8 rows)
+
+/*+NoIndexScan(t1) TidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoIndexScan(t1)
+TidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoIndexScan(t1) NoSeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoIndexScan(t1)
+NoSeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoIndexScan(t1) NoIndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoIndexScan(t1)
+NoIndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoIndexScan(t1) NoBitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoIndexScan(t1)
+NoBitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoIndexScan(t1) NoTidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoIndexScan(t1)
+NoTidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoBitmapScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoBitmapScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoBitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoBitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoBitmapScan(t1) SeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoBitmapScan(t1)
+SeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Seq Scan on t2
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoBitmapScan(t1) IndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoBitmapScan(t1)
+IndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoBitmapScan(t1) BitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoBitmapScan(t1)
+BitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t2
+         Recheck Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t2_pkey
+               Index Cond: (id = t1.id)
+(8 rows)
+
+/*+NoBitmapScan(t1) TidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoBitmapScan(t1)
+TidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoBitmapScan(t1) NoSeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoBitmapScan(t1)
+NoSeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoBitmapScan(t1) NoIndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoBitmapScan(t1)
+NoIndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoBitmapScan(t1) NoBitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoBitmapScan(t1)
+NoBitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoBitmapScan(t1) NoTidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoBitmapScan(t1)
+NoTidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoTidScan(t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoTidScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoTidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoTidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoTidScan(t1) SeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoTidScan(t1)
+SeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN               
+---------------------------------------
+ Nested Loop
+   ->  Seq Scan on t2
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoTidScan(t1) IndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoTidScan(t1)
+IndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN               
+---------------------------------------
+ Nested Loop
+   ->  Index Scan using t2_pkey on t2
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoTidScan(t1) BitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoTidScan(t1)
+BitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Nested Loop
+   ->  Seq Scan on t1
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Bitmap Heap Scan on t2
+         Recheck Cond: (id = t1.id)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t2_pkey
+               Index Cond: (id = t1.id)
+(8 rows)
+
+/*+NoTidScan(t1) TidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoTidScan(t1)
+TidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoTidScan(t1) NoSeqScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoTidScan(t1)
+NoSeqScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoTidScan(t1) NoIndexScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoTidScan(t1)
+NoIndexScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoTidScan(t1) NoBitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoTidScan(t1)
+NoBitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+/*+NoTidScan(t1) NoTidScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+NoTidScan(t1)
+NoTidScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN               
+---------------------------------------
+ Nested Loop
+   ->  Seq Scan on t2
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id = t2.id)
+         Filter: (ctid = '(1,1)'::tid)
+(6 rows)
+
+-- additional test
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)' AND t1.id < 10 AND t2.id < 10;
+               QUERY PLAN                
+-----------------------------------------
+ Nested Loop
+   Join Filter: (t1.id = t2.id)
+   ->  Tid Scan on t1
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: (id < 10)
+   ->  Tid Scan on t2
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: (id < 10)
+(8 rows)
+
+/*+BitmapScan(t1) BitmapScan(t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)' AND t1.id < 10 AND t2.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(t1)
+BitmapScan(t2)
+not used hint:
+duplication hint:
+error hint:
+
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Nested Loop
+   ->  Bitmap Heap Scan on t2
+         Recheck Cond: (id < 10)
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t2_pkey
+               Index Cond: (id < 10)
+   ->  Bitmap Heap Scan on t1
+         Recheck Cond: ((id = t2.id) AND (id < 10))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on t1_pkey
+               Index Cond: ((id = t2.id) AND (id < 10))
+(11 rows)
+
+-- outer join test
+EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN  t2 ON (t1.id = t2.id);
+          QUERY PLAN          
+------------------------------
+ Hash Full Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Seq Scan on t2
+(5 rows)
+
+/*+MergeJoin(t1 t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN  t2 ON (t1.id = t2.id);
+LOG:  pg_hint_plan:
+used hint:
+MergeJoin(t1 t2)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN              
+--------------------------------------
+ Merge Full Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+-- Cannot work
+/*+NestLoop(t1 t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN  t2 ON (t1.id = t2.id);
+LOG:  pg_hint_plan:
+used hint:
+NestLoop(t1 t2)
+not used hint:
+duplication hint:
+error hint:
+
+          QUERY PLAN          
+------------------------------
+ Hash Full Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Seq Scan on t2
+(5 rows)
+
+-- inheritance tables test
+SET constraint_exclusion TO off;
+EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+                              QUERY PLAN                               
+-----------------------------------------------------------------------
+ Append
+   ->  Seq Scan on p1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c2
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c3
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c4
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c1_c1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c1_c2
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c3_c1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c3_c2
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(19 rows)
+
+SET constraint_exclusion TO on;
+EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+                              QUERY PLAN                               
+-----------------------------------------------------------------------
+ Append
+   ->  Seq Scan on p1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c1_c1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c1_c2
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(9 rows)
+
+SET constraint_exclusion TO off;
+/*+SeqScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                              QUERY PLAN                               
+-----------------------------------------------------------------------
+ Append
+   ->  Seq Scan on p1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c2
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c3
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c4
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c1_c1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c1_c2
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c3_c1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c3_c2
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(19 rows)
+
+/*+IndexScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Append
+   ->  Index Scan using p1_pkey on p1
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using p1_c1_pkey on p1_c1
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using p1_c2_pkey on p1_c2
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using p1_c3_pkey on p1_c3
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using p1_c4_pkey on p1_c4
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using p1_c1_c1_pkey on p1_c1_c1
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using p1_c1_c2_pkey on p1_c1_c2
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using p1_c3_c1_pkey on p1_c3_c1
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using p1_c3_c2_pkey on p1_c3_c2
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+(28 rows)
+
+/*+BitmapScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                      QUERY PLAN                       
+-------------------------------------------------------
+ Append
+   ->  Bitmap Heap Scan on p1
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Bitmap Heap Scan on p1_c1
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_c1_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Bitmap Heap Scan on p1_c2
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_c2_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Bitmap Heap Scan on p1_c3
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_c3_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Bitmap Heap Scan on p1_c4
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_c4_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Bitmap Heap Scan on p1_c1_c1
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_c1_c1_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Bitmap Heap Scan on p1_c1_c2
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_c1_c2_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Bitmap Heap Scan on p1_c3_c1
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_c3_c1_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Bitmap Heap Scan on p1_c3_c2
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_c3_c2_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+(46 rows)
+
+/*+TidScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                  
+---------------------------------------------
+ Append
+   ->  Tid Scan on p1
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+   ->  Tid Scan on p1_c1
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+   ->  Tid Scan on p1_c2
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+   ->  Tid Scan on p1_c3
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+   ->  Tid Scan on p1_c4
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+   ->  Tid Scan on p1_c1_c1
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+   ->  Tid Scan on p1_c1_c2
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+   ->  Tid Scan on p1_c3_c1
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+   ->  Tid Scan on p1_c3_c2
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+(28 rows)
+
+SET constraint_exclusion TO on;
+/*+SeqScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                              QUERY PLAN                               
+-----------------------------------------------------------------------
+ Append
+   ->  Seq Scan on p1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c1_c1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p1_c1_c2
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(9 rows)
+
+/*+IndexScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Append
+   ->  Index Scan using p1_pkey on p1
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using p1_c1_pkey on p1_c1
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using p1_c1_c1_pkey on p1_c1_c1
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using p1_c1_c2_pkey on p1_c1_c2
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+(13 rows)
+
+/*+BitmapScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                      QUERY PLAN                       
+-------------------------------------------------------
+ Append
+   ->  Bitmap Heap Scan on p1
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Bitmap Heap Scan on p1_c1
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_c1_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Bitmap Heap Scan on p1_c1_c1
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_c1_c1_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Bitmap Heap Scan on p1_c1_c2
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_c1_c2_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+(21 rows)
+
+/*+TidScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                  
+---------------------------------------------
+ Append
+   ->  Tid Scan on p1
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+   ->  Tid Scan on p1_c1
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+   ->  Tid Scan on p1_c1_c1
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+   ->  Tid Scan on p1_c1_c2
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+(13 rows)
+
+SET constraint_exclusion TO off;
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+                                    QUERY PLAN                                     
+-----------------------------------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Sort
+         Sort Key: p1.id
+         ->  Append
+               ->  Seq Scan on p1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c3
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c4
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c3_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c3_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(25 rows)
+
+SET constraint_exclusion TO on;
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+                                    QUERY PLAN                                     
+-----------------------------------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Sort
+         Sort Key: p1.id
+         ->  Append
+               ->  Seq Scan on p1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(15 rows)
+
+SET constraint_exclusion TO off;
+/*+SeqScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                                    QUERY PLAN                                     
+-----------------------------------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Sort
+         Sort Key: p1.id
+         ->  Append
+               ->  Seq Scan on p1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c3
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c4
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c3_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c3_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(25 rows)
+
+/*+IndexScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Merge Append
+         Sort Key: p1.id
+         ->  Index Scan using p1_pkey on p1
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c1_pkey on p1_c1
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c2_pkey on p1_c2
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c3_pkey on p1_c3
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c4_pkey on p1_c4
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c1_c1_pkey on p1_c1_c1
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c1_c2_pkey on p1_c1_c2
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c3_c1_pkey on p1_c3_c1
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c3_c2_pkey on p1_c3_c2
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(33 rows)
+
+/*+BitmapScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                            QUERY PLAN                             
+-------------------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Sort
+         Sort Key: p1.id
+         ->  Append
+               ->  Bitmap Heap Scan on p1
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c1
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c2
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c2_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c3
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c3_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c4
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c4_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c1_c1
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c1_c1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c1_c2
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c1_c2_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c3_c1
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c3_c1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c3_c2
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c3_c2_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(52 rows)
+
+/*+TidScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+TidScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                       QUERY PLAN                        
+---------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Sort
+         Sort Key: p1.id
+         ->  Append
+               ->  Tid Scan on p1
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c1
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c2
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c3
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c4
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c1_c1
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c1_c2
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c3_c1
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c3_c2
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(34 rows)
+
+/*+NestLoop(p1 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+NestLoop(p1 t1)
+not used hint:
+duplication hint:
+error hint:
+
+                                 QUERY PLAN                                  
+-----------------------------------------------------------------------------
+ Nested Loop
+   Join Filter: (p1.id = t1.id)
+   ->  Append
+         ->  Seq Scan on p1
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c1
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c2
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c3
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c4
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c1_c1
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c1_c2
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c3_c1
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c3_c2
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Materialize
+         ->  Index Scan using t1_pkey on t1
+               Index Cond: (id < 10)
+(24 rows)
+
+/*+MergeJoin(p1 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+MergeJoin(p1 t1)
+not used hint:
+duplication hint:
+error hint:
+
+                                    QUERY PLAN                                     
+-----------------------------------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Sort
+         Sort Key: p1.id
+         ->  Append
+               ->  Seq Scan on p1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c3
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c4
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c3_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c3_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(25 rows)
+
+/*+HashJoin(p1 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+HashJoin(p1 t1)
+not used hint:
+duplication hint:
+error hint:
+
+                                 QUERY PLAN                                  
+-----------------------------------------------------------------------------
+ Hash Join
+   Hash Cond: (p1.id = t1.id)
+   ->  Append
+         ->  Seq Scan on p1
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c1
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c2
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c3
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c4
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c1_c1
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c1_c2
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c3_c1
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+         ->  Seq Scan on p1_c3_c2
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Hash
+         ->  Index Scan using t1_pkey on t1
+               Index Cond: (id < 10)
+(24 rows)
+
+SET constraint_exclusion TO on;
+/*+SeqScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                                    QUERY PLAN                                     
+-----------------------------------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Sort
+         Sort Key: p1.id
+         ->  Append
+               ->  Seq Scan on p1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(15 rows)
+
+/*+IndexScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Merge Append
+         Sort Key: p1.id
+         ->  Index Scan using p1_pkey on p1
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c1_pkey on p1_c1
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c1_c1_pkey on p1_c1_c1
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c1_c2_pkey on p1_c1_c2
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(18 rows)
+
+/*+BitmapScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                            QUERY PLAN                             
+-------------------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Sort
+         Sort Key: p1.id
+         ->  Append
+               ->  Bitmap Heap Scan on p1
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c1
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c1_c1
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c1_c1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c1_c2
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c1_c2_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(27 rows)
+
+/*+TidScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+TidScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                       QUERY PLAN                        
+---------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Sort
+         Sort Key: p1.id
+         ->  Append
+               ->  Tid Scan on p1
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c1
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c1_c1
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c1_c2
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(19 rows)
+
+/*+NestLoop(p1 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+NestLoop(p1 t1)
+not used hint:
+duplication hint:
+error hint:
+
+                                    QUERY PLAN                                     
+-----------------------------------------------------------------------------------
+ Nested Loop
+   Join Filter: (p1.id = t1.id)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+   ->  Materialize
+         ->  Append
+               ->  Seq Scan on p1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(14 rows)
+
+/*+MergeJoin(p1 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+MergeJoin(p1 t1)
+not used hint:
+duplication hint:
+error hint:
+
+                                    QUERY PLAN                                     
+-----------------------------------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Sort
+         Sort Key: p1.id
+         ->  Append
+               ->  Seq Scan on p1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(15 rows)
+
+/*+HashJoin(p1 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+HashJoin(p1 t1)
+not used hint:
+duplication hint:
+error hint:
+
+                                    QUERY PLAN                                     
+-----------------------------------------------------------------------------------
+ Hash Join
+   Hash Cond: (t1.id = p1.id)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+   ->  Hash
+         ->  Append
+               ->  Seq Scan on p1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c1
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Seq Scan on p1_c1_c2
+                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(14 rows)
+
+SET constraint_exclusion TO off;
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+                           QUERY PLAN                            
+-----------------------------------------------------------------
+ Seq Scan on p1
+   Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(2 rows)
+
+SET constraint_exclusion TO on;
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+                           QUERY PLAN                            
+-----------------------------------------------------------------
+ Seq Scan on p1
+   Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(2 rows)
+
+SET constraint_exclusion TO off;
+/*+SeqScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                           QUERY PLAN                            
+-----------------------------------------------------------------
+ Seq Scan on p1
+   Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(2 rows)
+
+/*+IndexScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                 
+-------------------------------------------
+ Index Scan using p1_pkey on p1
+   Index Cond: ((id >= 50) AND (id <= 51))
+   Filter: (ctid = '(1,1)'::tid)
+(3 rows)
+
+/*+BitmapScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                   QUERY PLAN                    
+-------------------------------------------------
+ Bitmap Heap Scan on p1
+   Recheck Cond: ((id >= 50) AND (id <= 51))
+   Filter: (ctid = '(1,1)'::tid)
+   ->  Bitmap Index Scan on p1_pkey
+         Index Cond: ((id >= 50) AND (id <= 51))
+(5 rows)
+
+/*+TidScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN               
+---------------------------------------
+ Tid Scan on p1
+   TID Cond: (ctid = '(1,1)'::tid)
+   Filter: ((id >= 50) AND (id <= 51))
+(3 rows)
+
+/*+NestLoop(p1 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+NestLoop(p1 t1)
+not used hint:
+duplication hint:
+error hint:
+
+                              QUERY PLAN                               
+-----------------------------------------------------------------------
+ Nested Loop
+   Join Filter: (p1.id = t1.id)
+   ->  Seq Scan on p1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(6 rows)
+
+/*+MergeJoin(p1 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+MergeJoin(p1 t1)
+not used hint:
+duplication hint:
+error hint:
+
+                                 QUERY PLAN                                  
+-----------------------------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Sort
+         Sort Key: p1.id
+         ->  Seq Scan on p1
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(8 rows)
+
+/*+HashJoin(p1 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+HashJoin(p1 t1)
+not used hint:
+duplication hint:
+error hint:
+
+                                 QUERY PLAN                                  
+-----------------------------------------------------------------------------
+ Hash Join
+   Hash Cond: (t1.id = p1.id)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+   ->  Hash
+         ->  Seq Scan on p1
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(7 rows)
+
+SET constraint_exclusion TO on;
+/*+SeqScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                           QUERY PLAN                            
+-----------------------------------------------------------------
+ Seq Scan on p1
+   Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(2 rows)
+
+/*+IndexScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                 
+-------------------------------------------
+ Index Scan using p1_pkey on p1
+   Index Cond: ((id >= 50) AND (id <= 51))
+   Filter: (ctid = '(1,1)'::tid)
+(3 rows)
+
+/*+BitmapScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                   QUERY PLAN                    
+-------------------------------------------------
+ Bitmap Heap Scan on p1
+   Recheck Cond: ((id >= 50) AND (id <= 51))
+   Filter: (ctid = '(1,1)'::tid)
+   ->  Bitmap Index Scan on p1_pkey
+         Index Cond: ((id >= 50) AND (id <= 51))
+(5 rows)
+
+/*+TidScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
+LOG:  pg_hint_plan:
+used hint:
+TidScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN               
+---------------------------------------
+ Tid Scan on p1
+   TID Cond: (ctid = '(1,1)'::tid)
+   Filter: ((id >= 50) AND (id <= 51))
+(3 rows)
+
+/*+NestLoop(p1 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+NestLoop(p1 t1)
+not used hint:
+duplication hint:
+error hint:
+
+                              QUERY PLAN                               
+-----------------------------------------------------------------------
+ Nested Loop
+   Join Filter: (p1.id = t1.id)
+   ->  Seq Scan on p1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(6 rows)
+
+/*+MergeJoin(p1 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+MergeJoin(p1 t1)
+not used hint:
+duplication hint:
+error hint:
+
+                                 QUERY PLAN                                  
+-----------------------------------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Sort
+         Sort Key: p1.id
+         ->  Seq Scan on p1
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(8 rows)
+
+/*+HashJoin(p1 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+HashJoin(p1 t1)
+not used hint:
+duplication hint:
+error hint:
+
+                                 QUERY PLAN                                  
+-----------------------------------------------------------------------------
+ Hash Join
+   Hash Cond: (t1.id = p1.id)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+   ->  Hash
+         ->  Seq Scan on p1
+               Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(7 rows)
+
+SET constraint_exclusion TO off;
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+                              QUERY PLAN                               
+-----------------------------------------------------------------------
+ Nested Loop
+   Join Filter: (p1.id = t1.id)
+   ->  Seq Scan on p1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(6 rows)
+
+SET constraint_exclusion TO on;
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+                              QUERY PLAN                               
+-----------------------------------------------------------------------
+ Nested Loop
+   Join Filter: (p1.id = t1.id)
+   ->  Seq Scan on p1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(6 rows)
+
+SET constraint_exclusion TO off;
+/*+SeqScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                              QUERY PLAN                               
+-----------------------------------------------------------------------
+ Nested Loop
+   Join Filter: (p1.id = t1.id)
+   ->  Seq Scan on p1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(6 rows)
+
+/*+IndexScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                   QUERY PLAN                    
+-------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Index Scan using p1_pkey on p1
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(7 rows)
+
+/*+BitmapScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                      QUERY PLAN                       
+-------------------------------------------------------
+ Nested Loop
+   Join Filter: (p1.id = t1.id)
+   ->  Bitmap Heap Scan on p1
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(9 rows)
+
+/*+TidScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+TidScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                  
+---------------------------------------------
+ Nested Loop
+   Join Filter: (p1.id = t1.id)
+   ->  Tid Scan on p1
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(7 rows)
+
+SET constraint_exclusion TO on;
+/*+SeqScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                              QUERY PLAN                               
+-----------------------------------------------------------------------
+ Nested Loop
+   Join Filter: (p1.id = t1.id)
+   ->  Seq Scan on p1
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(6 rows)
+
+/*+IndexScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                   QUERY PLAN                    
+-------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
+   ->  Index Scan using p1_pkey on p1
+         Index Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(7 rows)
+
+/*+BitmapScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+BitmapScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                      QUERY PLAN                       
+-------------------------------------------------------
+ Nested Loop
+   Join Filter: (p1.id = t1.id)
+   ->  Bitmap Heap Scan on p1
+         Recheck Cond: ((id >= 50) AND (id <= 51))
+         Filter: (ctid = '(1,1)'::tid)
+         ->  Bitmap Index Scan on p1_pkey
+               Index Cond: ((id >= 50) AND (id <= 51))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(9 rows)
+
+/*+TidScan(p1)*/
+EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+TidScan(p1)
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                  
+---------------------------------------------
+ Nested Loop
+   Join Filter: (p1.id = t1.id)
+   ->  Tid Scan on p1
+         TID Cond: (ctid = '(1,1)'::tid)
+         Filter: ((id >= 50) AND (id <= 51))
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+(7 rows)
+
+-- IndexScan is safe for unordered indexes
+CREATE TABLE ischk (a text, b tsvector) PARTITION BY LIST(a);
+CREATE TABLE ischk_d1 PARTITION OF ischk FOR VALUES IN (0);
+CREATE TABLE ischk_d2 PARTITION OF ischk FOR VALUES IN (1);
+CREATE INDEX ischk_idx ON ischk USING gin (b);
+/*+ IndexScan(ischk ischk_idx) */
+EXPLAIN (COSTS false) SELECT * FROM ischk WHERE b = 'x';
+LOG:  available indexes for IndexScan(ischk_d1): ischk_d1_b_idx
+LOG:  available indexes for IndexScan(ischk_d2): ischk_d2_b_idx
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(ischk ischk_idx)
+not used hint:
+duplication hint:
+error hint:
+
+               QUERY PLAN                
+-----------------------------------------
+ Append
+   ->  Seq Scan on ischk_d1
+         Filter: (b = '''x'''::tsvector)
+   ->  Seq Scan on ischk_d2
+         Filter: (b = '''x'''::tsvector)
+(5 rows)
+
+DROP TABLE ischk;
+-- quote test
+/*+SeqScan("""t1 )	")IndexScan("t	2 """)HashJoin("""t1 )	"T3"t	2 """)Leading("""t1 )	"T3"t	2 """)Set(application_name"a	a	a""	a	A")*/
+EXPLAIN (COSTS false) SELECT * FROM t1 """t1 )	", t2 "t	2 """, t3 "T3" WHERE """t1 )	".id = "t	2 """.id AND """t1 )	".id = "T3".id;
+LOG:  pg_hint_plan:
+used hint:
+SeqScan("""t1 )	")
+IndexScan("t	2 """)
+HashJoin("""t1 )	" T3 "t	2 """)
+Leading("""t1 )	" T3 "t	2 """)
+Set(application_name "a	a	a""	a	A")
+not used hint:
+duplication hint:
+error hint:
+
+                       QUERY PLAN                        
+---------------------------------------------------------
+ Hash Join
+   Hash Cond: ("t        2 """.id = """t1 )      ".id)
+   ->  Index Scan using t2_pkey on t2 "t 2 """
+   ->  Hash
+         ->  Hash Join
+               Hash Cond: ("""t1 )       ".id = "T3".id)
+               ->  Seq Scan on t1 """t1 )        "
+               ->  Hash
+                     ->  Seq Scan on t3 "T3"
+(9 rows)
+
+-- duplicate hint test
+/*+SeqScan(t1)SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
+INFO:  pg_hint_plan: hint syntax error at or near "SeqScan(t1)SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+DETAIL:  Conflict scan method hint.
+INFO:  pg_hint_plan: hint syntax error at or near "IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+DETAIL:  Conflict scan method hint.
+INFO:  pg_hint_plan: hint syntax error at or near "BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+DETAIL:  Conflict scan method hint.
+INFO:  pg_hint_plan: hint syntax error at or near "SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+DETAIL:  Conflict scan method hint.
+INFO:  pg_hint_plan: hint syntax error at or near "IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+DETAIL:  Conflict scan method hint.
+INFO:  pg_hint_plan: hint syntax error at or near "BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+DETAIL:  Conflict scan method hint.
+INFO:  pg_hint_plan: hint syntax error at or near "HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+DETAIL:  Conflict join method hint.
+INFO:  pg_hint_plan: hint syntax error at or near "NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+DETAIL:  Conflict join method hint.
+INFO:  pg_hint_plan: hint syntax error at or near "Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+DETAIL:  Conflict set hint.
+INFO:  pg_hint_plan: hint syntax error at or near "Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+DETAIL:  Conflict leading hint.
+LOG:  pg_hint_plan:
+used hint:
+TidScan(t1)
+TidScan(t2)
+MergeJoin(t1 t2)
+Leading(t2 t1)
+Set(enable_mergejoin on)
+Set(enable_seqscan on)
+not used hint:
+duplication hint:
+SeqScan(t1)
+IndexScan(t1)
+BitmapScan(t1)
+SeqScan(t2)
+IndexScan(t2)
+BitmapScan(t2)
+HashJoin(t1 t2)
+NestLoop(t1 t2)
+Leading(t1 t2)
+Set(enable_seqscan off)
+error hint:
+
+                  QUERY PLAN                   
+-----------------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Sort
+         Sort Key: t1.id
+         ->  Tid Scan on t1
+               TID Cond: (ctid = '(1,1)'::tid)
+   ->  Sort
+         Sort Key: t2.id
+         ->  Tid Scan on t2
+               TID Cond: (ctid = '(1,1)'::tid)
+(10 rows)
+
+-- sub query Leading hint test
+SET from_collapse_limit TO 100;
+SET geqo_threshold TO 100;
+EXPLAIN (COSTS false)
+WITH c1_1(id) AS (
+SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id
+)
+SELECT t1_1.id, (
+SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id
+) FROM t1 t1_1, t2 t2_1, t3 t3_1, (
+SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id
+) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = (
+SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id 
+);
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Nested Loop
+   InitPlan 1 (returns $0)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_2.id = t3_2.id)
+                 ->  Merge Join
+                       Merge Cond: (t1_2.id = t2_2.id)
+                       ->  Index Only Scan using t1_pkey on t1 t1_2
+                       ->  Index Only Scan using t2_pkey on t2 t2_2
+                 ->  Sort
+                       Sort Key: t3_2.id
+                       ->  Seq Scan on t3 t3_2
+   InitPlan 2 (returns $1)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_4.id = t3_4.id)
+                 ->  Merge Join
+                       Merge Cond: (t1_4.id = t2_4.id)
+                       ->  Index Only Scan using t1_pkey on t1 t1_4
+                       ->  Index Only Scan using t2_pkey on t2 t2_4
+                 ->  Sort
+                       Sort Key: t3_4.id
+                       ->  Seq Scan on t3 t3_4
+   ->  Nested Loop
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Nested Loop
+                           ->  Nested Loop
+                                 ->  Index Only Scan using t1_pkey on t1 t1_1
+                                       Index Cond: (id = $1)
+                                 ->  Index Only Scan using t2_pkey on t2 t2_1
+                                       Index Cond: (id = $1)
+                           ->  Seq Scan on t3 t3_1
+                                 Filter: (id = $1)
+                     ->  Index Only Scan using t1_pkey on t1 t1_3
+                           Index Cond: (id = $1)
+               ->  Index Only Scan using t2_pkey on t2 t2_3
+                     Index Cond: (id = $1)
+         ->  Seq Scan on t3 t3_3
+               Filter: (id = $1)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $1)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Merge Join
+                     Merge Cond: (t1_5.id = t2_5.id)
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
+
+/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)*/
+EXPLAIN (COSTS false)
+WITH c1_1(id) AS (
+SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id
+)
+SELECT t1_1.id, (
+SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id
+) FROM t1 t1_1, t2 t2_1, t3 t3_1, (
+SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id
+) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = (
+SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id 
+);
+LOG:  pg_hint_plan:
+used hint:
+HashJoin(t1_1 t3_1)
+NestLoop(t1_2 t2_2)
+MergeJoin(t1_3 t3_3)
+NestLoop(t1_4 t2_4)
+NestLoop(t1_5 t2_5)
+not used hint:
+duplication hint:
+error hint:
+
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Nested Loop
+   InitPlan 1 (returns $1)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_2.id = t3_2.id)
+                 ->  Nested Loop
+                       ->  Index Only Scan using t2_pkey on t2 t2_2
+                       ->  Index Only Scan using t1_pkey on t1 t1_2
+                             Index Cond: (id = t2_2.id)
+                 ->  Sort
+                       Sort Key: t3_2.id
+                       ->  Seq Scan on t3 t3_2
+   InitPlan 2 (returns $3)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_4.id = t3_4.id)
+                 ->  Nested Loop
+                       ->  Index Only Scan using t2_pkey on t2 t2_4
+                       ->  Index Only Scan using t1_pkey on t1 t1_4
+                             Index Cond: (id = t2_4.id)
+                 ->  Sort
+                       Sort Key: t3_4.id
+                       ->  Seq Scan on t3 t3_4
+   ->  Nested Loop
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Nested Loop
+                           ->  Nested Loop
+                                 ->  Index Only Scan using t1_pkey on t1 t1_1
+                                       Index Cond: (id = $3)
+                                 ->  Index Only Scan using t2_pkey on t2 t2_1
+                                       Index Cond: (id = $3)
+                           ->  Seq Scan on t3 t3_1
+                                 Filter: (id = $3)
+                     ->  Index Only Scan using t1_pkey on t1 t1_3
+                           Index Cond: (id = $3)
+               ->  Index Only Scan using t2_pkey on t2 t2_3
+                     Index Cond: (id = $3)
+         ->  Seq Scan on t3 t3_3
+               Filter: (id = $3)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $3)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Nested Loop
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                           Index Cond: (id = t2_5.id)
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
+
+/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t1_1 t1_2 t1_4 t1_5)*/
+EXPLAIN (COSTS false)
+WITH c1_1(id) AS (
+SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id
+)
+SELECT t1_1.id, (
+SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id
+) FROM t1 t1_1, t2 t2_1, t3 t3_1, (
+SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id
+) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = (
+SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id 
+);
+LOG:  pg_hint_plan:
+used hint:
+HashJoin(t1_1 t3_1)
+NestLoop(t1_2 t2_2)
+MergeJoin(t1_3 t3_3)
+NestLoop(t1_4 t2_4)
+NestLoop(t1_5 t2_5)
+not used hint:
+Leading(a t1_1 t1_2 t1_4 t1_5)
+duplication hint:
+error hint:
+
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Nested Loop
+   InitPlan 1 (returns $1)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_2.id = t3_2.id)
+                 ->  Nested Loop
+                       ->  Index Only Scan using t2_pkey on t2 t2_2
+                       ->  Index Only Scan using t1_pkey on t1 t1_2
+                             Index Cond: (id = t2_2.id)
+                 ->  Sort
+                       Sort Key: t3_2.id
+                       ->  Seq Scan on t3 t3_2
+   InitPlan 2 (returns $3)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_4.id = t3_4.id)
+                 ->  Nested Loop
+                       ->  Index Only Scan using t2_pkey on t2 t2_4
+                       ->  Index Only Scan using t1_pkey on t1 t1_4
+                             Index Cond: (id = t2_4.id)
+                 ->  Sort
+                       Sort Key: t3_4.id
+                       ->  Seq Scan on t3 t3_4
+   ->  Nested Loop
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Nested Loop
+                           ->  Nested Loop
+                                 ->  Index Only Scan using t1_pkey on t1 t1_1
+                                       Index Cond: (id = $3)
+                                 ->  Index Only Scan using t2_pkey on t2 t2_1
+                                       Index Cond: (id = $3)
+                           ->  Seq Scan on t3 t3_1
+                                 Filter: (id = $3)
+                     ->  Index Only Scan using t1_pkey on t1 t1_3
+                           Index Cond: (id = $3)
+               ->  Index Only Scan using t2_pkey on t2 t2_3
+                     Index Cond: (id = $3)
+         ->  Seq Scan on t3 t3_3
+               Filter: (id = $3)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $3)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Nested Loop
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                           Index Cond: (id = t2_5.id)
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
+
+/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1)*/
+EXPLAIN (COSTS false)
+WITH c1_1(id) AS (
+SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id
+)
+SELECT t1_1.id, (
+SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id
+) FROM t1 t1_1, t2 t2_1, t3 t3_1, (
+SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id
+) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = (
+SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id 
+);
+LOG:  pg_hint_plan:
+used hint:
+HashJoin(t1_1 t3_1)
+NestLoop(t1_2 t2_2)
+MergeJoin(t1_3 t3_3)
+NestLoop(t1_4 t2_4)
+NestLoop(t1_5 t2_5)
+not used hint:
+Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1)
+duplication hint:
+error hint:
+
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Nested Loop
+   InitPlan 1 (returns $1)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_2.id = t3_2.id)
+                 ->  Nested Loop
+                       ->  Index Only Scan using t2_pkey on t2 t2_2
+                       ->  Index Only Scan using t1_pkey on t1 t1_2
+                             Index Cond: (id = t2_2.id)
+                 ->  Sort
+                       Sort Key: t3_2.id
+                       ->  Seq Scan on t3 t3_2
+   InitPlan 2 (returns $3)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_4.id = t3_4.id)
+                 ->  Nested Loop
+                       ->  Index Only Scan using t2_pkey on t2 t2_4
+                       ->  Index Only Scan using t1_pkey on t1 t1_4
+                             Index Cond: (id = t2_4.id)
+                 ->  Sort
+                       Sort Key: t3_4.id
+                       ->  Seq Scan on t3 t3_4
+   ->  Nested Loop
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Nested Loop
+                           ->  Nested Loop
+                                 ->  Index Only Scan using t1_pkey on t1 t1_1
+                                       Index Cond: (id = $3)
+                                 ->  Index Only Scan using t2_pkey on t2 t2_1
+                                       Index Cond: (id = $3)
+                           ->  Seq Scan on t3 t3_1
+                                 Filter: (id = $3)
+                     ->  Index Only Scan using t1_pkey on t1 t1_3
+                           Index Cond: (id = $3)
+               ->  Index Only Scan using t2_pkey on t2 t2_3
+                     Index Cond: (id = $3)
+         ->  Seq Scan on t3 t3_3
+               Filter: (id = $3)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $3)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Nested Loop
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                           Index Cond: (id = t2_5.id)
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
+
+/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(t3_5 t2_5 t1_5)Leading(t3_2 t2_2 t1_2)Leading(t3_4 t2_4 t1_4)Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1)*/
+EXPLAIN (COSTS false)
+WITH c1_1(id) AS (
+SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id
+)
+SELECT t1_1.id, (
+SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id
+) FROM t1 t1_1, t2 t2_1, t3 t3_1, (
+SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id
+) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = (
+SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id 
+);
+LOG:  pg_hint_plan:
+used hint:
+Leading(t3_5 t2_5 t1_5)
+Leading(t3_2 t2_2 t1_2)
+Leading(t3_4 t2_4 t1_4)
+Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1)
+not used hint:
+HashJoin(t1_1 t3_1)
+NestLoop(t1_2 t2_2)
+MergeJoin(t1_3 t3_3)
+NestLoop(t1_4 t2_4)
+NestLoop(t1_5 t2_5)
+duplication hint:
+error hint:
+
+                                           QUERY PLAN                                           
+------------------------------------------------------------------------------------------------
+ Nested Loop
+   InitPlan 1 (returns $0)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t2_2.id = t1_2.id)
+                 ->  Merge Join
+                       Merge Cond: (t2_2.id = t3_2.id)
+                       ->  Index Only Scan using t2_pkey on t2 t2_2
+                       ->  Sort
+                             Sort Key: t3_2.id
+                             ->  Seq Scan on t3 t3_2
+                 ->  Index Only Scan using t1_pkey on t1 t1_2
+   InitPlan 2 (returns $1)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t2_4.id = t1_4.id)
+                 ->  Merge Join
+                       Merge Cond: (t2_4.id = t3_4.id)
+                       ->  Index Only Scan using t2_pkey on t2 t2_4
+                       ->  Sort
+                             Sort Key: t3_4.id
+                             ->  Seq Scan on t3 t3_4
+                 ->  Index Only Scan using t1_pkey on t1 t1_4
+   ->  Nested Loop
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Nested Loop
+                           ->  Nested Loop
+                                 ->  Seq Scan on t3 t3_3
+                                       Filter: (id = $1)
+                                 ->  Aggregate
+                                       Filter: (max(t1_5.id) = $1)
+                                       ->  Merge Join
+                                             Merge Cond: (t2_5.id = t1_5.id)
+                                             ->  Merge Join
+                                                   Merge Cond: (t2_5.id = t3_5.id)
+                                                   ->  Index Only Scan using t2_pkey on t2 t2_5
+                                                   ->  Sort
+                                                         Sort Key: t3_5.id
+                                                         ->  Seq Scan on t3 t3_5
+                                             ->  Index Only Scan using t1_pkey on t1 t1_5
+                           ->  Index Only Scan using t2_pkey on t2 t2_3
+                                 Index Cond: (id = $1)
+                     ->  Index Only Scan using t1_pkey on t1 t1_3
+                           Index Cond: (id = $1)
+               ->  Seq Scan on t3 t3_1
+                     Filter: (id = $1)
+         ->  Index Only Scan using t2_pkey on t2 t2_1
+               Index Cond: (id = $1)
+   ->  Index Only Scan using t1_pkey on t1 t1_1
+         Index Cond: (id = $1)
+(51 rows)
+
+SET from_collapse_limit TO 1;
+EXPLAIN (COSTS false)
+WITH c1_1(id) AS (
+SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id
+)
+SELECT t1_1.id, (
+SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id
+) FROM t1 t1_1, t2 t2_1, t3 t3_1, (
+SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id
+) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = (
+SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id 
+);
+                             QUERY PLAN                             
+--------------------------------------------------------------------
+ Nested Loop
+   InitPlan 1 (returns $0)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_2.id = t3_2.id)
+                 ->  Merge Join
+                       Merge Cond: (t1_2.id = t2_2.id)
+                       ->  Index Only Scan using t1_pkey on t1 t1_2
+                       ->  Index Only Scan using t2_pkey on t2 t2_2
+                 ->  Sort
+                       Sort Key: t3_2.id
+                       ->  Seq Scan on t3 t3_2
+   InitPlan 2 (returns $1)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_4.id = t3_4.id)
+                 ->  Merge Join
+                       Merge Cond: (t1_4.id = t2_4.id)
+                       ->  Index Only Scan using t1_pkey on t1 t1_4
+                       ->  Index Only Scan using t2_pkey on t2 t2_4
+                 ->  Sort
+                       Sort Key: t3_4.id
+                       ->  Seq Scan on t3 t3_4
+   ->  Nested Loop
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Index Only Scan using t1_pkey on t1 t1_1
+                           Index Cond: (id = $1)
+                     ->  Index Only Scan using t2_pkey on t2 t2_1
+                           Index Cond: (id = $1)
+               ->  Seq Scan on t3 t3_1
+                     Filter: (id = $1)
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Index Only Scan using t1_pkey on t1 t1_3
+                           Index Cond: (id = $1)
+                     ->  Index Only Scan using t2_pkey on t2 t2_3
+                           Index Cond: (id = $1)
+               ->  Seq Scan on t3 t3_3
+                     Filter: (id = $1)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $1)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Merge Join
+                     Merge Cond: (t1_5.id = t2_5.id)
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
+
+/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)*/
+EXPLAIN (COSTS false)
+WITH c1_1(id) AS (
+SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id
+)
+SELECT t1_1.id, (
+SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id
+) FROM t1 t1_1, t2 t2_1, t3 t3_1, (
+SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id
+) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = (
+SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id 
+);
+LOG:  pg_hint_plan:
+used hint:
+HashJoin(t1_1 t3_1)
+NestLoop(t1_2 t2_2)
+MergeJoin(t1_3 t3_3)
+NestLoop(t1_4 t2_4)
+NestLoop(t1_5 t2_5)
+not used hint:
+duplication hint:
+error hint:
+
+                             QUERY PLAN                             
+--------------------------------------------------------------------
+ Nested Loop
+   InitPlan 1 (returns $1)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_2.id = t3_2.id)
+                 ->  Nested Loop
+                       ->  Index Only Scan using t2_pkey on t2 t2_2
+                       ->  Index Only Scan using t1_pkey on t1 t1_2
+                             Index Cond: (id = t2_2.id)
+                 ->  Sort
+                       Sort Key: t3_2.id
+                       ->  Seq Scan on t3 t3_2
+   InitPlan 2 (returns $3)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_4.id = t3_4.id)
+                 ->  Nested Loop
+                       ->  Index Only Scan using t2_pkey on t2 t2_4
+                       ->  Index Only Scan using t1_pkey on t1 t1_4
+                             Index Cond: (id = t2_4.id)
+                 ->  Sort
+                       Sort Key: t3_4.id
+                       ->  Seq Scan on t3 t3_4
+   ->  Nested Loop
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Index Only Scan using t1_pkey on t1 t1_1
+                           Index Cond: (id = $3)
+                     ->  Index Only Scan using t2_pkey on t2 t2_1
+                           Index Cond: (id = $3)
+               ->  Seq Scan on t3 t3_1
+                     Filter: (id = $3)
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Index Only Scan using t1_pkey on t1 t1_3
+                           Index Cond: (id = $3)
+                     ->  Index Only Scan using t2_pkey on t2 t2_3
+                           Index Cond: (id = $3)
+               ->  Seq Scan on t3 t3_3
+                     Filter: (id = $3)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $3)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Nested Loop
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                           Index Cond: (id = t2_5.id)
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
+
+/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t1_1 t1_2 t1_4 t1_5)*/
+EXPLAIN (COSTS false)
+WITH c1_1(id) AS (
+SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id
+)
+SELECT t1_1.id, (
+SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id
+) FROM t1 t1_1, t2 t2_1, t3 t3_1, (
+SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id
+) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = (
+SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id 
+);
+LOG:  pg_hint_plan:
+used hint:
+HashJoin(t1_1 t3_1)
+NestLoop(t1_2 t2_2)
+MergeJoin(t1_3 t3_3)
+NestLoop(t1_4 t2_4)
+NestLoop(t1_5 t2_5)
+not used hint:
+Leading(a t1_1 t1_2 t1_4 t1_5)
+duplication hint:
+error hint:
+
+                             QUERY PLAN                             
+--------------------------------------------------------------------
+ Nested Loop
+   InitPlan 1 (returns $1)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_2.id = t3_2.id)
+                 ->  Nested Loop
+                       ->  Index Only Scan using t2_pkey on t2 t2_2
+                       ->  Index Only Scan using t1_pkey on t1 t1_2
+                             Index Cond: (id = t2_2.id)
+                 ->  Sort
+                       Sort Key: t3_2.id
+                       ->  Seq Scan on t3 t3_2
+   InitPlan 2 (returns $3)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_4.id = t3_4.id)
+                 ->  Nested Loop
+                       ->  Index Only Scan using t2_pkey on t2 t2_4
+                       ->  Index Only Scan using t1_pkey on t1 t1_4
+                             Index Cond: (id = t2_4.id)
+                 ->  Sort
+                       Sort Key: t3_4.id
+                       ->  Seq Scan on t3 t3_4
+   ->  Nested Loop
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Index Only Scan using t1_pkey on t1 t1_1
+                           Index Cond: (id = $3)
+                     ->  Index Only Scan using t2_pkey on t2 t2_1
+                           Index Cond: (id = $3)
+               ->  Seq Scan on t3 t3_1
+                     Filter: (id = $3)
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Index Only Scan using t1_pkey on t1 t1_3
+                           Index Cond: (id = $3)
+                     ->  Index Only Scan using t2_pkey on t2 t2_3
+                           Index Cond: (id = $3)
+               ->  Seq Scan on t3 t3_3
+                     Filter: (id = $3)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $3)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Nested Loop
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                           Index Cond: (id = t2_5.id)
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
+
+/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1)*/
+EXPLAIN (COSTS false)
+WITH c1_1(id) AS (
+SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id
+)
+SELECT t1_1.id, (
+SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id
+) FROM t1 t1_1, t2 t2_1, t3 t3_1, (
+SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id
+) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = (
+SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id 
+);
+LOG:  pg_hint_plan:
+used hint:
+HashJoin(t1_1 t3_1)
+NestLoop(t1_2 t2_2)
+MergeJoin(t1_3 t3_3)
+NestLoop(t1_4 t2_4)
+NestLoop(t1_5 t2_5)
+not used hint:
+Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1)
+duplication hint:
+error hint:
+
+                             QUERY PLAN                             
+--------------------------------------------------------------------
+ Nested Loop
+   InitPlan 1 (returns $1)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_2.id = t3_2.id)
+                 ->  Nested Loop
+                       ->  Index Only Scan using t2_pkey on t2 t2_2
+                       ->  Index Only Scan using t1_pkey on t1 t1_2
+                             Index Cond: (id = t2_2.id)
+                 ->  Sort
+                       Sort Key: t3_2.id
+                       ->  Seq Scan on t3 t3_2
+   InitPlan 2 (returns $3)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t1_4.id = t3_4.id)
+                 ->  Nested Loop
+                       ->  Index Only Scan using t2_pkey on t2 t2_4
+                       ->  Index Only Scan using t1_pkey on t1 t1_4
+                             Index Cond: (id = t2_4.id)
+                 ->  Sort
+                       Sort Key: t3_4.id
+                       ->  Seq Scan on t3 t3_4
+   ->  Nested Loop
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Index Only Scan using t1_pkey on t1 t1_1
+                           Index Cond: (id = $3)
+                     ->  Index Only Scan using t2_pkey on t2 t2_1
+                           Index Cond: (id = $3)
+               ->  Seq Scan on t3 t3_1
+                     Filter: (id = $3)
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Index Only Scan using t1_pkey on t1 t1_3
+                           Index Cond: (id = $3)
+                     ->  Index Only Scan using t2_pkey on t2 t2_3
+                           Index Cond: (id = $3)
+               ->  Seq Scan on t3 t3_3
+                     Filter: (id = $3)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $3)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Nested Loop
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                           Index Cond: (id = t2_5.id)
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
+
+/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(t3_5 t2_5 t1_5)Leading(t3_2 t2_2 t1_2)Leading(t3_4 t2_4 t1_4)Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1)*/
+EXPLAIN (COSTS false)
+WITH c1_1(id) AS (
+SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id
+)
+SELECT t1_1.id, (
+SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id
+) FROM t1 t1_1, t2 t2_1, t3 t3_1, (
+SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id
+) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = (
+SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id 
+);
+LOG:  pg_hint_plan:
+used hint:
+MergeJoin(t1_3 t3_3)
+Leading(t3_5 t2_5 t1_5)
+Leading(t3_2 t2_2 t1_2)
+Leading(t3_4 t2_4 t1_4)
+Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1)
+not used hint:
+HashJoin(t1_1 t3_1)
+NestLoop(t1_2 t2_2)
+NestLoop(t1_4 t2_4)
+NestLoop(t1_5 t2_5)
+duplication hint:
+error hint:
+
+                                     QUERY PLAN                                     
+------------------------------------------------------------------------------------
+ Nested Loop
+   InitPlan 1 (returns $0)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t2_2.id = t1_2.id)
+                 ->  Merge Join
+                       Merge Cond: (t2_2.id = t3_2.id)
+                       ->  Index Only Scan using t2_pkey on t2 t2_2
+                       ->  Sort
+                             Sort Key: t3_2.id
+                             ->  Seq Scan on t3 t3_2
+                 ->  Index Only Scan using t1_pkey on t1 t1_2
+   InitPlan 2 (returns $1)
+     ->  Aggregate
+           ->  Merge Join
+                 Merge Cond: (t2_4.id = t1_4.id)
+                 ->  Merge Join
+                       Merge Cond: (t2_4.id = t3_4.id)
+                       ->  Index Only Scan using t2_pkey on t2 t2_4
+                       ->  Sort
+                             Sort Key: t3_4.id
+                             ->  Seq Scan on t3 t3_4
+                 ->  Index Only Scan using t1_pkey on t1 t1_4
+   ->  Nested Loop
+         ->  Nested Loop
+               ->  Nested Loop
+                     ->  Nested Loop
+                           ->  Nested Loop
+                                 ->  Index Only Scan using t1_pkey on t1 t1_3
+                                       Index Cond: (id = $1)
+                                 ->  Index Only Scan using t2_pkey on t2 t2_3
+                                       Index Cond: (id = $1)
+                           ->  Seq Scan on t3 t3_3
+                                 Filter: (id = $1)
+                     ->  Aggregate
+                           Filter: (max(t1_5.id) = $1)
+                           ->  Merge Join
+                                 Merge Cond: (t2_5.id = t1_5.id)
+                                 ->  Merge Join
+                                       Merge Cond: (t2_5.id = t3_5.id)
+                                       ->  Index Only Scan using t2_pkey on t2 t2_5
+                                       ->  Sort
+                                             Sort Key: t3_5.id
+                                             ->  Seq Scan on t3 t3_5
+                                 ->  Index Only Scan using t1_pkey on t1 t1_5
+               ->  Seq Scan on t3 t3_1
+                     Filter: (id = $1)
+         ->  Index Only Scan using t2_pkey on t2 t2_1
+               Index Cond: (id = $1)
+   ->  Index Only Scan using t1_pkey on t1 t1_1
+         Index Cond: (id = $1)
+(51 rows)
+
+-- ambigous error
+EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id;
+                   QUERY PLAN                    
+-------------------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Merge Join
+         Merge Cond: (t1.id = t1_1.id)
+         ->  Index Scan using t1_pkey on t1
+         ->  Index Scan using t1_pkey on t1 t1_1
+   ->  Index Scan using t2_pkey on t2
+(7 rows)
+
+/*+NestLoop(t1 t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id;
+INFO:  pg_hint_plan: hint syntax error at or near "NestLoop(t1 t2)"
+DETAIL:  Relation name "t1" is ambiguous.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+NestLoop(t1 t2)
+
+                   QUERY PLAN                    
+-------------------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Merge Join
+         Merge Cond: (t1.id = t1_1.id)
+         ->  Index Scan using t1_pkey on t1
+         ->  Index Scan using t1_pkey on t1 t1_1
+   ->  Index Scan using t2_pkey on t2
+(7 rows)
+
+/*+Leading(t1 t2 t1)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id;
+INFO:  pg_hint_plan: hint syntax error at or near "Leading(t1 t2 t1)"
+DETAIL:  Relation name "t1" is ambiguous.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Leading(t1 t2 t1)
+
+                   QUERY PLAN                    
+-------------------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Merge Join
+         Merge Cond: (t1.id = t1_1.id)
+         ->  Index Scan using t1_pkey on t1
+         ->  Index Scan using t1_pkey on t1 t1_1
+   ->  Index Scan using t2_pkey on t2
+(7 rows)
+
+-- identifier length test
+EXPLAIN (COSTS false) SELECT * FROM t1 "123456789012345678901234567890123456789012345678901234567890123" JOIN t2 ON ("123456789012345678901234567890123456789012345678901234567890123".id = t2.id) JOIN t3 ON (t2.id = t3.id);
+                                                  QUERY PLAN                                                  
+--------------------------------------------------------------------------------------------------------------
+ Merge Join
+   Merge Cond: ("123456789012345678901234567890123456789012345678901234567890123".id = t3.id)
+   ->  Merge Join
+         Merge Cond: ("123456789012345678901234567890123456789012345678901234567890123".id = t2.id)
+         ->  Index Scan using t1_pkey on t1 "123456789012345678901234567890123456789012345678901234567890123"
+         ->  Index Scan using t2_pkey on t2
+   ->  Sort
+         Sort Key: t3.id
+         ->  Seq Scan on t3
+(9 rows)
+
+/*+
+Leading(123456789012345678901234567890123456789012345678901234567890123 t2 t3)
+SeqScan(123456789012345678901234567890123456789012345678901234567890123)
+MergeJoin(123456789012345678901234567890123456789012345678901234567890123 t2)
+Set(123456789012345678901234567890123456789012345678901234567890123 1)
+*/
+EXPLAIN (COSTS false) SELECT * FROM t1 "123456789012345678901234567890123456789012345678901234567890123" JOIN t2 ON ("123456789012345678901234567890123456789012345678901234567890123".id = t2.id) JOIN t3 ON (t2.id = t3.id);
+INFO:  unrecognized configuration parameter "123456789012345678901234567890123456789012345678901234567890123"
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(123456789012345678901234567890123456789012345678901234567890123)
+MergeJoin(123456789012345678901234567890123456789012345678901234567890123 t2)
+Leading(123456789012345678901234567890123456789012345678901234567890123 t2 t3)
+not used hint:
+duplication hint:
+error hint:
+Set(123456789012345678901234567890123456789012345678901234567890123 1)
+
+                                             QUERY PLAN                                             
+----------------------------------------------------------------------------------------------------
+ Merge Join
+   Merge Cond: ("123456789012345678901234567890123456789012345678901234567890123".id = t3.id)
+   ->  Merge Join
+         Merge Cond: (t2.id = "123456789012345678901234567890123456789012345678901234567890123".id)
+         ->  Index Scan using t2_pkey on t2
+         ->  Sort
+               Sort Key: "123456789012345678901234567890123456789012345678901234567890123".id
+               ->  Seq Scan on t1 "123456789012345678901234567890123456789012345678901234567890123"
+   ->  Sort
+         Sort Key: t3.id
+         ->  Seq Scan on t3
+(11 rows)
+
+/*+
+Leading(1234567890123456789012345678901234567890123456789012345678901234 t2 t3)
+SeqScan(1234567890123456789012345678901234567890123456789012345678901234)
+MergeJoin(1234567890123456789012345678901234567890123456789012345678901234 t2)
+Set(1234567890123456789012345678901234567890123456789012345678901234 1)
+Set(cursor_tuple_fraction 0.1234567890123456789012345678901234567890123456789012345678901234)
+*/
+EXPLAIN (COSTS false) SELECT * FROM t1 "1234567890123456789012345678901234567890123456789012345678901234" JOIN t2 ON ("1234567890123456789012345678901234567890123456789012345678901234".id = t2.id) JOIN t3 ON (t2.id = t3.id);
+NOTICE:  identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123"
+NOTICE:  identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123"
+NOTICE:  identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123"
+NOTICE:  identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123"
+NOTICE:  identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123"
+NOTICE:  identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123"
+INFO:  unrecognized configuration parameter "123456789012345678901234567890123456789012345678901234567890123"
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(123456789012345678901234567890123456789012345678901234567890123)
+MergeJoin(123456789012345678901234567890123456789012345678901234567890123 t2)
+Leading(123456789012345678901234567890123456789012345678901234567890123 t2 t3)
+Set(cursor_tuple_fraction 0.1234567890123456789012345678901234567890123456789012345678901234)
+not used hint:
+duplication hint:
+error hint:
+Set(123456789012345678901234567890123456789012345678901234567890123 1)
+
+                                             QUERY PLAN                                             
+----------------------------------------------------------------------------------------------------
+ Merge Join
+   Merge Cond: ("123456789012345678901234567890123456789012345678901234567890123".id = t3.id)
+   ->  Merge Join
+         Merge Cond: (t2.id = "123456789012345678901234567890123456789012345678901234567890123".id)
+         ->  Index Scan using t2_pkey on t2
+         ->  Sort
+               Sort Key: "123456789012345678901234567890123456789012345678901234567890123".id
+               ->  Seq Scan on t1 "123456789012345678901234567890123456789012345678901234567890123"
+   ->  Sort
+         Sort Key: t3.id
+         ->  Seq Scan on t3
+(11 rows)
+
+SET "123456789012345678901234567890123456789012345678901234567890123" TO 1;
+ERROR:  unrecognized configuration parameter "123456789012345678901234567890123456789012345678901234567890123"
+SET "1234567890123456789012345678901234567890123456789012345678901234" TO 1;
+NOTICE:  identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123"
+ERROR:  unrecognized configuration parameter "123456789012345678901234567890123456789012345678901234567890123"
+SET cursor_tuple_fraction TO 1234567890123456789012345678901234567890123456789012345678901234;
+ERROR:  1.23457e+63 is outside the valid range for parameter "cursor_tuple_fraction" (0 .. 1)
+-- multi error
+/*+ Set(enable_seqscan 100)Set(seq_page_cost on)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+INFO:  parameter "enable_seqscan" requires a Boolean value
+INFO:  invalid value for parameter "seq_page_cost": "on"
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Set(enable_seqscan 100)
+Set(seq_page_cost on)
+
+              QUERY PLAN              
+--------------------------------------
+ Merge Join
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Index Scan using t2_pkey on t2
+(4 rows)
+
+-- debug log of candidate index to use IndexScan
+EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1;
+                                       QUERY PLAN                                       
+----------------------------------------------------------------------------------------
+ Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
+   Index Cond: (id = 1)
+(2 rows)
+
+/*+IndexScan(t5 t5_id2)*/
+EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1;
+LOG:  available indexes for IndexScan(t5): t5_id2
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t5 t5_id2)
+not used hint:
+duplication hint:
+error hint:
+
+          QUERY PLAN           
+-------------------------------
+ Index Scan using t5_id2 on t5
+   Index Cond: (id = 1)
+(2 rows)
+
+/*+IndexScan(t5 no_exist)*/
+EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1;
+LOG:  available indexes for IndexScan(t5):
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t5 no_exist)
+not used hint:
+duplication hint:
+error hint:
+
+     QUERY PLAN     
+--------------------
+ Seq Scan on t5
+   Filter: (id = 1)
+(2 rows)
+
+/*+IndexScan(t5 t5_id1 t5_id2)*/
+EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1;
+LOG:  available indexes for IndexScan(t5): t5_id2 t5_id1
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t5 t5_id1 t5_id2)
+not used hint:
+duplication hint:
+error hint:
+
+          QUERY PLAN           
+-------------------------------
+ Index Scan using t5_id2 on t5
+   Index Cond: (id = 1)
+(2 rows)
+
+/*+IndexScan(t5 no_exist t5_id2)*/
+EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1;
+LOG:  available indexes for IndexScan(t5): t5_id2
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t5 no_exist t5_id2)
+not used hint:
+duplication hint:
+error hint:
+
+          QUERY PLAN           
+-------------------------------
+ Index Scan using t5_id2 on t5
+   Index Cond: (id = 1)
+(2 rows)
+
+/*+IndexScan(t5 no_exist5 no_exist2)*/
+EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1;
+LOG:  available indexes for IndexScan(t5):
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t5 no_exist5 no_exist2)
+not used hint:
+duplication hint:
+error hint:
+
+     QUERY PLAN     
+--------------------
+ Seq Scan on t5
+   Filter: (id = 1)
+(2 rows)
+
+-- outer inner
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Hash Join
+   Hash Cond: (t3.val = t2.val)
+   ->  Seq Scan on t3
+   ->  Hash
+         ->  Hash Join
+               Hash Cond: (t2.id = t1.id)
+               ->  Seq Scan on t2
+               ->  Hash
+                     ->  Index Scan using t1_pkey on t1
+                           Index Cond: (id < 10)
+(10 rows)
+
+/*+Leading((t1))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+INFO:  pg_hint_plan: hint syntax error at or near "Leading((t1))"
+DETAIL:  Leading hint requires two sets of relations when parentheses nests.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Leading((t1))
+
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Hash Join
+   Hash Cond: (t3.val = t2.val)
+   ->  Seq Scan on t3
+   ->  Hash
+         ->  Hash Join
+               Hash Cond: (t2.id = t1.id)
+               ->  Seq Scan on t2
+               ->  Hash
+                     ->  Index Scan using t1_pkey on t1
+                           Index Cond: (id < 10)
+(10 rows)
+
+/*+Leading((t1 t2))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+Leading((t1 t2))
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                 
+--------------------------------------------
+ Nested Loop
+   Join Filter: (t2.val = t3.val)
+   ->  Hash Join
+         Hash Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+               Index Cond: (id < 10)
+         ->  Hash
+               ->  Seq Scan on t2
+   ->  Seq Scan on t3
+(9 rows)
+
+/*+Leading((t1 t2 t3))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+INFO:  pg_hint_plan: hint syntax error at or near "Leading((t1 t2 t3))"
+DETAIL:  Leading hint requires two sets of relations when parentheses nests.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Leading((t1 t2 t3))
+
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Hash Join
+   Hash Cond: (t3.val = t2.val)
+   ->  Seq Scan on t3
+   ->  Hash
+         ->  Hash Join
+               Hash Cond: (t2.id = t1.id)
+               ->  Seq Scan on t2
+               ->  Hash
+                     ->  Index Scan using t1_pkey on t1
+                           Index Cond: (id < 10)
+(10 rows)
+
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.id < 10;
+                 QUERY PLAN                 
+--------------------------------------------
+ Hash Join
+   Hash Cond: (t2.id = t1.id)
+   ->  Seq Scan on t2
+   ->  Hash
+         ->  Index Scan using t1_pkey on t1
+               Index Cond: (id < 10)
+(6 rows)
+
+/*+Leading((t1 t2))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+Leading((t1 t2))
+not used hint:
+duplication hint:
+error hint:
+
+              QUERY PLAN              
+--------------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+   ->  Hash
+         ->  Seq Scan on t2
+(6 rows)
+
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Hash Join
+   Hash Cond: (t3.val = t2.val)
+   ->  Seq Scan on t3
+   ->  Hash
+         ->  Hash Join
+               Hash Cond: (t2.id = t1.id)
+               ->  Seq Scan on t2
+               ->  Hash
+                     ->  Index Scan using t1_pkey on t1
+                           Index Cond: (id < 10)
+(10 rows)
+
+/*+Leading(((t1 t2) t3))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+Leading(((t1 t2) t3))
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                 
+--------------------------------------------
+ Nested Loop
+   Join Filter: (t2.val = t3.val)
+   ->  Hash Join
+         Hash Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+               Index Cond: (id < 10)
+         ->  Hash
+               ->  Seq Scan on t2
+   ->  Seq Scan on t3
+(9 rows)
+
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10;
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t3.id = t4.id)
+         ->  Nested Loop
+               Join Filter: (t1.val = t3.val)
+               ->  Index Scan using t3_pkey on t3
+               ->  Materialize
+                     ->  Index Scan using t1_pkey on t1
+                           Index Cond: (id < 10)
+         ->  Sort
+               Sort Key: t4.id
+               ->  Seq Scan on t4
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+(14 rows)
+
+/*+Leading((((t1 t2) t3) t4))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+Leading((((t1 t2) t3) t4))
+not used hint:
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Nested Loop
+   ->  Nested Loop
+         Join Filter: (t1.val = t3.val)
+         ->  Hash Join
+               Hash Cond: (t1.id = t2.id)
+               ->  Index Scan using t1_pkey on t1
+                     Index Cond: (id < 10)
+               ->  Hash
+                     ->  Seq Scan on t2
+         ->  Seq Scan on t3
+   ->  Index Scan using t4_pkey on t4
+         Index Cond: (id = t3.id)
+(12 rows)
+
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Hash Join
+   Hash Cond: (t3.val = t2.val)
+   ->  Seq Scan on t3
+   ->  Hash
+         ->  Hash Join
+               Hash Cond: (t2.id = t1.id)
+               ->  Seq Scan on t2
+               ->  Hash
+                     ->  Index Scan using t1_pkey on t1
+                           Index Cond: (id < 10)
+(10 rows)
+
+/*+Leading(((t1 t2) t3))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+Leading(((t1 t2) t3))
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                 
+--------------------------------------------
+ Nested Loop
+   Join Filter: (t2.val = t3.val)
+   ->  Hash Join
+         Hash Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+               Index Cond: (id < 10)
+         ->  Hash
+               ->  Seq Scan on t2
+   ->  Seq Scan on t3
+(9 rows)
+
+/*+Leading((t1 (t2 t3)))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+Leading((t1 (t2 t3)))
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                 
+--------------------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+   ->  Hash
+         ->  Hash Join
+               Hash Cond: (t2.val = t3.val)
+               ->  Seq Scan on t2
+               ->  Hash
+                     ->  Seq Scan on t3
+(10 rows)
+
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10;
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t3.id = t4.id)
+         ->  Nested Loop
+               Join Filter: (t1.val = t3.val)
+               ->  Index Scan using t3_pkey on t3
+               ->  Materialize
+                     ->  Index Scan using t1_pkey on t1
+                           Index Cond: (id < 10)
+         ->  Sort
+               Sort Key: t4.id
+               ->  Seq Scan on t4
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+(14 rows)
+
+/*+Leading(((t1 t2) (t3 t4)))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+Leading(((t1 t2) (t3 t4)))
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                 
+--------------------------------------------
+ Nested Loop
+   Join Filter: (t1.val = t3.val)
+   ->  Hash Join
+         Hash Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+               Index Cond: (id < 10)
+         ->  Hash
+               ->  Seq Scan on t2
+   ->  Merge Join
+         Merge Cond: (t3.id = t4.id)
+         ->  Index Scan using t3_pkey on t3
+         ->  Sort
+               Sort Key: t4.id
+               ->  Seq Scan on t4
+(14 rows)
+
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < ( SELECT t1_2.id FROM t1 t1_2, t2 t2_2 WHERE t1_2.id = t2_2.id AND t2_2.val > 100 ORDER BY t1_2.id LIMIT 1);
+                             QUERY PLAN                             
+--------------------------------------------------------------------
+ Hash Join
+   Hash Cond: (t2.val = t3.val)
+   InitPlan 1 (returns $1)
+     ->  Limit
+           ->  Sort
+                 Sort Key: t1_2.id
+                 ->  Nested Loop
+                       ->  Index Scan using t2_val on t2 t2_2
+                             Index Cond: (val > 100)
+                       ->  Index Only Scan using t1_pkey on t1 t1_2
+                             Index Cond: (id = t2_2.id)
+   ->  Merge Join
+         Merge Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+               Index Cond: (id < $1)
+         ->  Index Scan using t2_pkey on t2
+   ->  Hash
+         ->  Seq Scan on t3
+(18 rows)
+
+/*+Leading(((t1 t2) t3)) Leading(((t3 t1) t2))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t1.val = t3.val AND t1.id < ( SELECT t1_2.id FROM t1 t1_2, t2 t2_2 WHERE t1_2.id = t2_2.id AND t2_2.val > 100 ORDER BY t1_2.id LIMIT 1);
+INFO:  pg_hint_plan: hint syntax error at or near "Leading(((t1 t2) t3)) Leading(((t3 t1) t2))"
+DETAIL:  Conflict leading hint.
+LOG:  pg_hint_plan:
+used hint:
+Leading(((t3 t1) t2))
+not used hint:
+duplication hint:
+Leading(((t1 t2) t3))
+error hint:
+
+                             QUERY PLAN                             
+--------------------------------------------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   InitPlan 1 (returns $1)
+     ->  Limit
+           ->  Sort
+                 Sort Key: t1_2.id
+                 ->  Nested Loop
+                       ->  Index Scan using t2_val on t2 t2_2
+                             Index Cond: (val > 100)
+                       ->  Index Only Scan using t1_pkey on t1 t1_2
+                             Index Cond: (id = t2_2.id)
+   ->  Hash Join
+         Hash Cond: (t3.val = t1.val)
+         ->  Seq Scan on t3
+         ->  Hash
+               ->  Index Scan using t1_pkey on t1
+                     Index Cond: (id < $1)
+   ->  Hash
+         ->  Seq Scan on t2
+(19 rows)
+
+/*+Leading(((t1 t2) t3)) Leading((t1_2 t2_2))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < ( SELECT t1_2.id FROM t1 t1_2, t2 t2_2 WHERE t1_2.id = t2_2.id AND t2_2.val > 100 ORDER BY t1_2.id LIMIT 1);
+LOG:  pg_hint_plan:
+used hint:
+Leading(((t1 t2) t3))
+Leading((t1_2 t2_2))
+not used hint:
+duplication hint:
+error hint:
+
+                          QUERY PLAN                          
+--------------------------------------------------------------
+ Hash Join
+   Hash Cond: (t2.val = t3.val)
+   InitPlan 1 (returns $0)
+     ->  Limit
+           ->  Merge Join
+                 Merge Cond: (t1_2.id = t2_2.id)
+                 ->  Index Only Scan using t1_pkey on t1 t1_2
+                 ->  Sort
+                       Sort Key: t2_2.id
+                       ->  Index Scan using t2_val on t2 t2_2
+                             Index Cond: (val > 100)
+   ->  Merge Join
+         Merge Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+               Index Cond: (id < $0)
+         ->  Index Scan using t2_pkey on t2
+   ->  Hash
+         ->  Seq Scan on t3
+(18 rows)
+
+/*+Leading(((((t1 t2) t3) t1_2) t2_2))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < ( SELECT t1_2.id FROM t1 t1_2, t2 t2_2 WHERE t1_2.id = t2_2.id AND t2_2.val > 100 ORDER BY t1_2.id LIMIT 1);
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+Leading(((((t1 t2) t3) t1_2) t2_2))
+duplication hint:
+error hint:
+
+                             QUERY PLAN                             
+--------------------------------------------------------------------
+ Hash Join
+   Hash Cond: (t2.val = t3.val)
+   InitPlan 1 (returns $1)
+     ->  Limit
+           ->  Sort
+                 Sort Key: t1_2.id
+                 ->  Nested Loop
+                       ->  Index Scan using t2_val on t2 t2_2
+                             Index Cond: (val > 100)
+                       ->  Index Only Scan using t1_pkey on t1 t1_2
+                             Index Cond: (id = t2_2.id)
+   ->  Merge Join
+         Merge Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+               Index Cond: (id < $1)
+         ->  Index Scan using t2_pkey on t2
+   ->  Hash
+         ->  Seq Scan on t3
+(18 rows)
+
+-- Specified outer/inner leading hint and join method hint at the same time
+/*+Leading(((t1 t2) t3))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+Leading(((t1 t2) t3))
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                 
+--------------------------------------------
+ Nested Loop
+   Join Filter: (t2.val = t3.val)
+   ->  Hash Join
+         Hash Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+               Index Cond: (id < 10)
+         ->  Hash
+               ->  Seq Scan on t2
+   ->  Seq Scan on t3
+(9 rows)
+
+/*+Leading(((t1 t2) t3)) MergeJoin(t1 t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+MergeJoin(t1 t2)
+Leading(((t1 t2) t3))
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                 
+--------------------------------------------
+ Nested Loop
+   Join Filter: (t2.val = t3.val)
+   ->  Merge Join
+         Merge Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+               Index Cond: (id < 10)
+         ->  Index Scan using t2_pkey on t2
+   ->  Seq Scan on t3
+(8 rows)
+
+/*+Leading(((t1 t2) t3)) MergeJoin(t1 t2 t3)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+MergeJoin(t1 t2 t3)
+Leading(((t1 t2) t3))
+not used hint:
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Merge Join
+   Merge Cond: (t2.val = t3.val)
+   ->  Sort
+         Sort Key: t2.val
+         ->  Hash Join
+               Hash Cond: (t1.id = t2.id)
+               ->  Index Scan using t1_pkey on t1
+                     Index Cond: (id < 10)
+               ->  Hash
+                     ->  Seq Scan on t2
+   ->  Sort
+         Sort Key: t3.val
+         ->  Seq Scan on t3
+(13 rows)
+
+/*+Leading(((t1 t2) t3)) MergeJoin(t1 t3)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+Leading(((t1 t2) t3))
+not used hint:
+MergeJoin(t1 t3)
+duplication hint:
+error hint:
+
+                 QUERY PLAN                 
+--------------------------------------------
+ Nested Loop
+   Join Filter: (t2.val = t3.val)
+   ->  Hash Join
+         Hash Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+               Index Cond: (id < 10)
+         ->  Hash
+               ->  Seq Scan on t2
+   ->  Seq Scan on t3
+(9 rows)
+
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10;
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t3.id = t4.id)
+         ->  Nested Loop
+               Join Filter: (t1.val = t3.val)
+               ->  Index Scan using t3_pkey on t3
+               ->  Materialize
+                     ->  Index Scan using t1_pkey on t1
+                           Index Cond: (id < 10)
+         ->  Sort
+               Sort Key: t4.id
+               ->  Seq Scan on t4
+   ->  Index Scan using t2_pkey on t2
+         Index Cond: (id = t1.id)
+(14 rows)
+
+/*+Leading(((t1 t2) t3)) MergeJoin(t3 t4)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+Leading(((t1 t2) t3))
+not used hint:
+MergeJoin(t3 t4)
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Nested Loop
+   Join Filter: (t3.id = t4.id)
+   ->  Nested Loop
+         Join Filter: (t1.val = t3.val)
+         ->  Hash Join
+               Hash Cond: (t1.id = t2.id)
+               ->  Index Scan using t1_pkey on t1
+                     Index Cond: (id < 10)
+               ->  Hash
+                     ->  Seq Scan on t2
+         ->  Seq Scan on t3
+   ->  Seq Scan on t4
+(12 rows)
+
+/*+Leading(((t1 t2) t3)) MergeJoin(t1 t2 t3 t4)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+MergeJoin(t1 t2 t3 t4)
+Leading(((t1 t2) t3))
+not used hint:
+duplication hint:
+error hint:
+
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Merge Join
+   Merge Cond: (t3.id = t4.id)
+   ->  Sort
+         Sort Key: t3.id
+         ->  Nested Loop
+               Join Filter: (t1.val = t3.val)
+               ->  Hash Join
+                     Hash Cond: (t1.id = t2.id)
+                     ->  Index Scan using t1_pkey on t1
+                           Index Cond: (id < 10)
+                     ->  Hash
+                           ->  Seq Scan on t2
+               ->  Seq Scan on t3
+   ->  Sort
+         Sort Key: t4.id
+         ->  Seq Scan on t4
+(16 rows)
+
+/*+ Leading ( ( t1 ( t2 t3 ) ) ) */
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+Leading((t1 (t2 t3)))
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                 
+--------------------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+   ->  Hash
+         ->  Hash Join
+               Hash Cond: (t2.val = t3.val)
+               ->  Seq Scan on t2
+               ->  Hash
+                     ->  Seq Scan on t3
+(10 rows)
+
+/*+Leading((t1(t2 t3)))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+Leading((t1 (t2 t3)))
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                 
+--------------------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+         Index Cond: (id < 10)
+   ->  Hash
+         ->  Hash Join
+               Hash Cond: (t2.val = t3.val)
+               ->  Seq Scan on t2
+               ->  Hash
+                     ->  Seq Scan on t3
+(10 rows)
+
+/*+Leading(("t1(t2" "t3)"))*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+Leading(("t1(t2" "t3)"))
+duplication hint:
+error hint:
+
+                       QUERY PLAN                       
+--------------------------------------------------------
+ Hash Join
+   Hash Cond: (t3.val = t2.val)
+   ->  Seq Scan on t3
+   ->  Hash
+         ->  Hash Join
+               Hash Cond: (t2.id = t1.id)
+               ->  Seq Scan on t2
+               ->  Hash
+                     ->  Index Scan using t1_pkey on t1
+                           Index Cond: (id < 10)
+(10 rows)
+
+/*+ Leading ( ( ( t1 t2 ) t3 ) ) */
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
+LOG:  pg_hint_plan:
+used hint:
+Leading(((t1 t2) t3))
+not used hint:
+duplication hint:
+error hint:
... 45818 lines suppressed ...


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org