List:Commits« Previous MessageNext Message »
From:Frazer Clement Date:November 1 2010 1:15pm
Subject:bzr commit into mysql-5.1-telco-6.3 branch (frazer:3330) Bug#57827
View as plain text  
#At file:///home/frazer/bzr/mysql-5.1-telco-6.3/ based on revid:jonas@stripped

 3330 Frazer Clement	2010-11-01
      Bug#57827 Adding UNIQUE index to disk data table is very slow with moderate amount of data
      
      Modify unique index build not to read disk based columns.

    modified:
      mysql-test/suite/ndb/r/ndb_index_unique.result
      mysql-test/suite/ndb/t/ndb_index_unique.test
      storage/ndb/include/kernel/signaldata/BuildIndx.hpp
      storage/ndb/include/kernel/signaldata/SumaImpl.hpp
      storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
      storage/ndb/src/kernel/blocks/suma/Suma.cpp
      storage/ndb/src/kernel/blocks/suma/Suma.hpp
      storage/ndb/src/kernel/blocks/trix/Trix.cpp
      storage/ndb/src/kernel/blocks/trix/Trix.hpp
=== modified file 'mysql-test/suite/ndb/r/ndb_index_unique.result'
--- a/mysql-test/suite/ndb/r/ndb_index_unique.result	2009-05-06 10:16:35 +0000
+++ b/mysql-test/suite/ndb/r/ndb_index_unique.result	2010-11-01 13:15:22 +0000
@@ -705,3 +705,35 @@ PRIMARY KEY(pk0, pk1),
 UNIQUE (col0) USING HASH
 ) engine = ndb;
 drop table t1, t2;
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile.dat'
+INITIAL_SIZE 8M
+UNDO_BUFFER_SIZE = 1M engine=ndb;
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 32M
+ENGINE NDB;
+use test;
+create table t1 (pk int primary key, un int, data varchar(500) storage disk) tablespace ts1 engine=ndb;
+insert into t1 values 
+(1,1,repeat('B', 500)),
+(2,2,repeat('B', 500)),
+(3,3,repeat('B', 500)),
+(4,4,repeat('B', 500)),
+(5,5,repeat('B', 500)),
+(6,6,repeat('B', 500)),
+(7,7,repeat('B', 500)),
+(8,8,repeat('B', 500)),
+(9,9,repeat('B', 500)),
+(10,10,repeat('B', 500)),
+(11,11,repeat('B', 500)),
+(12,12,repeat('B', 500)),
+(13,13,repeat('B', 500)),
+(14,14,repeat('B', 500)),
+(15,15,repeat('B', 500));
+alter table t1 add unique(un);
+drop table t1;
+alter tablespace ts1 drop datafile 'datafile.dat' engine=ndb;
+drop tablespace ts1 engine=ndb;
+drop logfile group lg1 engine=ndb;

=== modified file 'mysql-test/suite/ndb/t/ndb_index_unique.test'
--- a/mysql-test/suite/ndb/t/ndb_index_unique.test	2009-05-06 11:09:37 +0000
+++ b/mysql-test/suite/ndb/t/ndb_index_unique.test	2010-11-01 13:15:22 +0000
@@ -389,4 +389,48 @@ enable_query_log;
 
 drop table t1, t2;
 
-# end of tests
+# bug#57827 : Don't load dd columns when building unique index
+# Build a unique index in a table with DD columns to give
+# some coverage of the scenario
+#
+
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile.dat'
+INITIAL_SIZE 8M
+UNDO_BUFFER_SIZE = 1M engine=ndb;
+
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 32M
+ENGINE NDB;
+
+use test;
+
+create table t1 (pk int primary key, un int, data varchar(500) storage disk) tablespace ts1 engine=ndb;
+
+insert into t1 values 
+        (1,1,repeat('B', 500)),
+        (2,2,repeat('B', 500)),
+        (3,3,repeat('B', 500)),
+        (4,4,repeat('B', 500)),
+        (5,5,repeat('B', 500)),
+        (6,6,repeat('B', 500)),
+        (7,7,repeat('B', 500)),
+        (8,8,repeat('B', 500)),
+        (9,9,repeat('B', 500)),
+        (10,10,repeat('B', 500)),
+        (11,11,repeat('B', 500)),
+        (12,12,repeat('B', 500)),
+        (13,13,repeat('B', 500)),
+        (14,14,repeat('B', 500)),
+        (15,15,repeat('B', 500));
+
+alter table t1 add unique(un);
+
+drop table t1;
+alter tablespace ts1 drop datafile 'datafile.dat' engine=ndb;
+drop tablespace ts1 engine=ndb;
+drop logfile group lg1 engine=ndb;
+
+# end of tests
\ No newline at end of file

=== modified file 'storage/ndb/include/kernel/signaldata/BuildIndx.hpp'
--- a/storage/ndb/include/kernel/signaldata/BuildIndx.hpp	2010-01-13 08:56:02 +0000
+++ b/storage/ndb/include/kernel/signaldata/BuildIndx.hpp	2010-11-01 13:15:22 +0000
@@ -49,6 +49,7 @@ public:
 
   enum RequestFlag {
     RF_BUILD_OFFLINE = 1 << 3 // NOTE check Dbdict.hpp::RequestFlag & BuildIndx
+    ,RF_NO_DISK      = 1 << 5
   };
 
   STATIC_CONST( SignalLength = 9 );

=== modified file 'storage/ndb/include/kernel/signaldata/SumaImpl.hpp'
--- a/storage/ndb/include/kernel/signaldata/SumaImpl.hpp	2010-11-01 10:06:12 +0000
+++ b/storage/ndb/include/kernel/signaldata/SumaImpl.hpp	2010-11-01 13:15:22 +0000
@@ -271,13 +271,18 @@ struct SubSyncReq {
   friend struct Grep;
   
   friend bool printSUB_SYNC_REQ(FILE *, const Uint32 *, Uint32, Uint16);
-  STATIC_CONST( SignalLength = 5 );
+  STATIC_CONST( SignalLength = 6 );
   
   Uint32 senderRef;
   Uint32 senderData;
   Uint32 subscriptionId;
   Uint32 subscriptionKey;
   Uint32 part; // SubscriptionData::Part
+  Uint32 requestInfo;
+
+  enum {
+    NoDisk = 0x4
+  };
 
   SECTION( ATTRIBUTE_LIST = 0); // Used when doing SingelTableScan  
   SECTION( TABLE_LIST = 1 );

=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2010-10-21 11:45:41 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2010-11-01 13:15:22 +0000
@@ -13328,7 +13328,10 @@ Dbdict::buildIndex_buildTrix(Signal* sig
   req->setUserRef(reference());
   req->setConnectionPtr(opPtr.p->key);
   req->setRequestType(BuildIndxReq::RT_TRIX);
-  req->addRequestFlag(opPtr.p->m_requestFlag);
+  /* All indexed columns must be in memory currently */
+  Uint32 requestFlags = opPtr.p->m_requestFlag;
+  requestFlags |= BuildIndxReq::RF_NO_DISK;
+  req->addRequestFlag(requestFlags);
   req->setBuildId(0);   // not yet..
   req->setBuildKey(0);  // ..in use
   req->setIndexType(indexPtr.p->tableType);

=== modified file 'storage/ndb/src/kernel/blocks/suma/Suma.cpp'
--- a/storage/ndb/src/kernel/blocks/suma/Suma.cpp	2010-11-01 10:06:12 +0000
+++ b/storage/ndb/src/kernel/blocks/suma/Suma.cpp	2010-11-01 13:15:22 +0000
@@ -1996,7 +1996,8 @@ Suma::execSUB_SYNC_REQ(Signal* signal)
   syncPtr.p->m_subscriptionPtrI = subPtr.i;
   syncPtr.p->ptrI               = syncPtr.i;
   syncPtr.p->m_error            = 0;
-  
+  syncPtr.p->m_requestInfo      = req->requestInfo;
+
   {
     jam();
     syncPtr.p->m_tableList.append(&subPtr.p->m_tableId, 1);
@@ -2410,6 +2411,10 @@ Suma::SyncRecord::nextScan(Signal* signa
   ScanFragReq::setHoldLockFlag(req->requestInfo, 1);
   ScanFragReq::setKeyinfoFlag(req->requestInfo, 0);
   ScanFragReq::setAttrLen(req->requestInfo, attrLen);
+  if (m_requestInfo & SubSyncReq::NoDisk)
+  {
+    ScanFragReq::setNoDiskFlag(req->requestInfo, 1);
+  }
   req->fragmentNoKeyLen = fd.m_fragDesc.m_fragmentNo;
   req->schemaVersion = tabPtr.p->m_schemaVersion;
   req->transId1 = 0;

=== modified file 'storage/ndb/src/kernel/blocks/suma/Suma.hpp'
--- a/storage/ndb/src/kernel/blocks/suma/Suma.hpp	2010-11-01 10:06:12 +0000
+++ b/storage/ndb/src/kernel/blocks/suma/Suma.hpp	2010-11-01 13:15:22 +0000
@@ -163,6 +163,8 @@ public:
 
     Uint32 m_subscriptionPtrI;
     Uint32 m_error;
+    Uint32 m_requestInfo;
+
     Uint32 m_currentTable;
     TableList m_tableList;    // Tables to sync
     TableList::DataBufferIterator m_tableList_it;

=== modified file 'storage/ndb/src/kernel/blocks/trix/Trix.cpp'
--- a/storage/ndb/src/kernel/blocks/trix/Trix.cpp	2009-05-27 12:11:46 +0000
+++ b/storage/ndb/src/kernel/blocks/trix/Trix.cpp	2010-11-01 13:15:22 +0000
@@ -512,6 +512,11 @@ void Trix:: execBUILDINDXREQ(Signal* sig
   subRec->subscriptionCreated = false;
   subRec->pendingSubSyncContinueConf = false;
   subRec->prepareId = RNIL;
+  subRec->m_flags = 0;
+  if (buildIndxReq->getRequestFlag() & BuildIndxReq::RF_NO_DISK)
+  {
+    subRec->m_flags |= SubscriptionRecord::RF_NO_DISK;
+  }
 
   // Get column order segments
   Uint32 noOfSections = handle.m_cnt;
@@ -818,6 +823,12 @@ void Trix::startTableScan(Signal* signal
   subSyncReq->subscriptionId = subRec->subscriptionId;
   subSyncReq->subscriptionKey = subRec->subscriptionKey;
   subSyncReq->part = SubscriptionData::TableData;
+  subSyncReq->requestInfo = 0;
+  if (subRecPtr.p->m_flags & SubscriptionRecord::RF_NO_DISK)
+  {
+    jam();
+    subSyncReq->requestInfo |= SubSyncReq::NoDisk;
+  }
 
   subRecPtr.p->expectedConf = 1;
 

=== modified file 'storage/ndb/src/kernel/blocks/trix/Trix.hpp'
--- a/storage/ndb/src/kernel/blocks/trix/Trix.hpp	2009-10-08 09:55:36 +0000
+++ b/storage/ndb/src/kernel/blocks/trix/Trix.hpp	2010-11-01 13:15:22 +0000
@@ -104,6 +104,10 @@ private:
     SubscriptionRecord(AttrOrderBuffer::DataBufferPool & aop):
       attributeOrder(aop)
     {}
+    enum RequestFlags {
+      RF_NO_DISK = 0x2
+    };
+    Uint32 m_flags;
     RequestType requestType;
     BlockReference userReference; // For user
     Uint32 connectionPtr; // For user


Attachment: [text/bzr-bundle] bzr/frazer@mysql.com-20101101131522-33zap16jsi2lj8mw.bundle
Thread
bzr commit into mysql-5.1-telco-6.3 branch (frazer:3330) Bug#57827Frazer Clement1 Nov