pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: Jesper Pedersen <jesper.pedersen@redhat.com>
Cc: Simon Riggs <simon@2ndquadrant.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Cc: Maksim Milyutin <milyutinma@gmail.com>
Cc: Jaime Casanova <jaime.casanova@2ndquadrant.com>
Subject: Re: [HACKERS] Proposal: Local indexes for partitioned table
Date: Wed, 24 Jan 2018 13:20:06 -0300
Message-ID: <20180124162006.pmapfiznhgngwtjf@alvherre.pgsql> (raw)
In-Reply-To: <CAKJS1f9EOCx5w=F6wZB5O5AH5_EgqE1optRtXvbPb_Mmvni3AQ@mail.gmail.com>

David Rowley wrote:

> 10. You've added code to get_relation_info() to handle partitioned
> indexes, but that code is skipped due to:
> 
> /*
> * Make list of indexes.  Ignore indexes on system catalogs if told to.
> * Don't bother with indexes for an inheritance parent, either.
> */
> if (inhparent ||
> 
> The new code should either be removed, or you should load the index
> list for a partitioned table.

I realized that this wasn't an oversight after all.  You can invoke this
code, and it fails in current master:

CREATE TABLE at_partitioned (col1 INT) PARTITION BY RANGE (col1);
CREATE INDEX ON at_partitioned (col1);
CREATE TABLE at_regular2 (col2 INT);
SELECT col2 FROM at_regular2 fk LEFT OUTER JOIN at_partitioned pk ON (col1 = col2);

fails with:
ERROR:  could not open file "base/16384/16395": No such file or directory

where the mentioned path corresponds to the index filenode:

alvherre=# select oid::regclass, relkind from pg_class where relfilenode = '16395';
           oid           │ relkind 
─────────────────────────┼─────────
 at_partitioned_col1_idx │ I
(1 fila)


The error comes from get_relation_info called for at_partitioned, where the
rte->inh flag is false.  So this is the correct behavior:  we consider the
table on its own, not as an inheritance parent, and so the code is not skipped.
Backtrace:

(gdb) bt
#0  errfinish (dummy=0)
    at /pgsql/source/master/src/backend/utils/error/elog.c:414
#1  0x0000564936f79365 in mdopen (reln=<optimized out>, 
    forknum=forknum@entry=MAIN_FORKNUM, behavior=behavior@entry=1)
    at /pgsql/source/master/src/backend/storage/smgr/md.c:606
#2  0x0000564936f7983b in mdopen (behavior=1, forknum=MAIN_FORKNUM, 
    reln=0x5649382f8dd0)
    at /pgsql/source/master/src/backend/storage/smgr/md.c:922
#3  mdnblocks (reln=0x5649382f8dd0, forknum=MAIN_FORKNUM)
    at /pgsql/source/master/src/backend/storage/smgr/md.c:875
#4  0x0000564936eeb6ea in get_relation_info (root=root@entry=0x5649382ef398, 
    relationObjectId=16385, inhparent=<optimized out>, 
    rel=rel@entry=0x5649382f0198)
    at /pgsql/source/master/src/backend/optimizer/util/plancat.c:377
#5  0x0000564936eeee55 in build_simple_rel (root=root@entry=0x5649382ef398, 
    relid=2, parent=parent@entry=0x0)
    at /pgsql/source/master/src/backend/optimizer/util/relnode.c:182
#6  0x0000564936ec6f23 in add_base_rels_to_query (
    root=root@entry=0x5649382ef398, jtnode=<optimized out>)
    at /pgsql/source/master/src/backend/optimizer/plan/initsplan.c:113

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (142+ messages)  latest in thread

Message-ID: <20180124162006.pmapfiznhgngwtjf@alvherre.pgsql>
Permalink:  ../20180124162006.pmapfiznhgngwtjf@alvherre.pgsql/
Also on:    postgresql.org/message-id/20180124162006.pmapfiznhgngwtjf@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@alvh.no-ip.org, david.rowley@2ndquadrant.com, robertmhaas@gmail.com, peter.eisentraut@2ndquadrant.com, Langote_Amit_f8@lab.ntt.co.jp, jesper.pedersen@redhat.com, simon@2ndquadrant.com, milyutinma@gmail.com, jaime.casanova@2ndquadrant.com
  Subject: Re: [HACKERS] Proposal: Local indexes for partitioned table
  In-Reply-To: <20180124162006.pmapfiznhgngwtjf@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox