Skip to content
  • Magnus Blåudd's avatar
    497c4138
    Bug#31452597 BUILD ATTRID MAP FOR PRIMARY KEY · 497c4138
    Magnus Blåudd authored
    Mapping need to be performed when reading data using indexes or primary
    key whose column order is different than the column order of the NDB
    table. For unique indexes an attrid map is built when the table is
    opened which is then used for each subsequent read. For primary key
    reads the attrid map is built for every read.
    
    Since a way to cache the attrid map already exists, it seems like a good
    idea to build also the attrid map for primary key when opening the
    table. This way the implementation will have a more uniform code path
    for reads. Since the attridmap for indexes which have the same column
    order are well known, this also brings an opportunity to implement an
    optimization to not build an attrid map for the most common case.
    
    This table shows indexes whose columns are in different order than the
    NDB table column order:
      CREATE TABLE t1 (
        a int, b int, c int, d int, e int, f int, g int, h int,
        PRIMARY KEY(d,b,c),
        UNIQUE_KEY(e,d,c)
      ) engine = ndb;
    
    Fix by building cached attrid map also for primary key when opening the
    table and use it for subsequent reads.
    
    Also add the optimization to avoid building the attrid map when the
    column order are identical, this reduces the amount of memory which need
    to be allocated for the common case where columns are in same order.
    
    Change-Id: I9be76fc33a83ff82a54613decc0af8efe976f42f
    497c4138
    Bug#31452597 BUILD ATTRID MAP FOR PRIMARY KEY
    Magnus Blåudd authored
    Mapping need to be performed when reading data using indexes or primary
    key whose column order is different than the column order of the NDB
    table. For unique indexes an attrid map is built when the table is
    opened which is then used for each subsequent read. For primary key
    reads the attrid map is built for every read.
    
    Since a way to cache the attrid map already exists, it seems like a good
    idea to build also the attrid map for primary key when opening the
    table. This way the implementation will have a more uniform code path
    for reads. Since the attridmap for indexes which have the same column
    order are well known, this also brings an opportunity to implement an
    optimization to not build an attrid map for the most common case.
    
    This table shows indexes whose columns are in different order than the
    NDB table column order:
      CREATE TABLE t1 (
        a int, b int, c int, d int, e int, f int, g int, h int,
        PRIMARY KEY(d,b,c),
        UNIQUE_KEY(e,d,c)
      ) engine = ndb;
    
    Fix by building cached attrid map also for primary key when opening the
    table and use it for subsequent reads.
    
    Also add the optimization to avoid building the attrid map when the
    column order are identical, this reduces the amount of memory which need
    to be allocated for the common case where columns are in same order.
    
    Change-Id: I9be76fc33a83ff82a54613decc0af8efe976f42f
Loading