Below is the list of changes that have just been committed into a local
6.0-falcon repository of . When does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-05-19 16:52:39-04:00, jas@rowvwade. +8 -0
Maintain and set table cardinality for MySQL optimizer (work
in progress).
storage/falcon/Section.cpp@stripped, 2007-05-19 16:52:29-04:00, jas@rowvwade. +43 -0
Create mechanism to estimate cardinality.
storage/falcon/Section.h@stripped, 2007-05-19 16:52:30-04:00, jas@rowvwade. +4 -1
Create mechanism to estimate cardinality.
storage/falcon/StorageTableShare.cpp@stripped, 2007-05-19 16:52:30-04:00, jas@rowvwade. +5
-0
Maintain and set table cardinality for MySQL optimizer (work
in progress).
storage/falcon/StorageTableShare.h@stripped, 2007-05-19 16:52:30-04:00, jas@rowvwade. +1 -0
Maintain and set table cardinality for MySQL optimizer (work
in progress).
storage/falcon/Table.cpp@stripped, 2007-05-19 16:52:31-04:00, jas@rowvwade. +15 -0
Maintain and set table cardinality for MySQL optimizer (work
in progress).
storage/falcon/Table.h@stripped, 2007-05-19 16:52:31-04:00, jas@rowvwade. +3 -0
Maintain and set table cardinality for MySQL optimizer (work
in progress).
storage/falcon/Transaction.cpp@stripped, 2007-05-19 16:52:31-04:00, jas@rowvwade. +7 -0
Maintain table cardinality for MySQL optimizer.
storage/falcon/ha_falcon.cpp@stripped, 2007-05-19 16:52:32-04:00, jas@rowvwade. +1 -0
Maintain and set table cardinality for MySQL optimizer (work
in progress).
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: jas
# Host: rowvwade.
# Root: D:/MySQL/mysql-5.1-falcon
--- 1.42/storage/falcon/Section.cpp 2007-05-19 16:52:56 -04:00
+++ 1.43/storage/falcon/Section.cpp 2007-05-19 16:52:56 -04:00
@@ -1270,3 +1270,46 @@
page->setIndexSlot(locatorLine, dataPage, dataLine, dbb->pageSize);
bdb->release();
}
+
+uint64 Section::estimateCardinality(void)
+{
+ Bdb *bdb = dbb->fetchPage(root, PAGE_sections, Shared);
+ SectionPage *sectionPage = (SectionPage*) bdb->buffer;
+ int64 sequence = estimateCardinality(sectionPage);
+ bdb->release();
+
+ return (sequence >= 0) ? sequence * dbb->linesPerPage : 0;
+}
+
+int64 Section::estimateCardinality(SectionPage* sectionPage)
+{
+ if (sectionPage->level == 0)
+ {
+ for (uint n = dbb->pagesPerSection - 1; n >= 0; --n)
+ if (sectionPage->pages[n])
+ {
+ Bdb *bdb = dbb->fetchPage(sectionPage->pages[n], PAGE_record_locator, Shared);
+ RecordLocatorPage *locatorPage = (RecordLocatorPage*) bdb->buffer;
+ int64 sequence = locatorPage->sequence;
+ bdb->release();
+
+ return sequence;
+ }
+
+ return -1;
+ }
+
+ for (uint n = dbb->pagesPerSection - 1; n >= 0; --n)
+ if (sectionPage->pages[n])
+ {
+ Bdb *bdb = dbb->fetchPage(sectionPage->pages[n], PAGE_record_locator, Shared);
+ SectionPage *childPage = (SectionPage*) bdb->buffer;
+ int64 sequence = estimateCardinality(childPage);
+ bdb->release();
+
+ if (sequence >= 0)
+ return sequence;
+ }
+
+ return -1;
+}
--- 1.18/storage/falcon/Section.h 2007-05-19 16:52:56 -04:00
+++ 1.19/storage/falcon/Section.h 2007-05-19 16:52:56 -04:00
@@ -34,6 +34,7 @@
class Validation;
class Bitmap;
class RecordLocatorPage;
+class SectionPage;
struct RecordIndex;
struct SectionAnalysis;
@@ -60,6 +61,8 @@
int32 getSectionRoot();
Bdb* getSectionPage(int sequence, LockType lockType, TransId transId);
Bdb* fetchIndexPage (int32 root, int32 recordNumber, LockType lockType, TransId
transId);
+ uint64 estimateCardinality(void);
+ int64 estimateCardinality(SectionPage* sectionPage);
static void redoSectionPromotion(Dbb* dbb, int sectionId, int32 rootPageNumber, int
pageLength, const UCHAR* pageData, int32 newPageNumber);
void redoRecordLocatorPage(int sequence, int32 pageNumber);
@@ -77,6 +80,7 @@
static void createSection (Dbb *dbb, int32 sectionId, TransId transId);
static void redoSectionPage(Dbb *dbb, int32 parentPage, int32 pageNumber, int slot, int
sectionId, int sequence, int level);
static bool dataPageInUse(Dbb* dbb, int32 recordLocatorPage, int32 dataPage);
+ static void redoBlobUpdate(Dbb* dbb, int32 locatorPage, int locatorLine, int32
dataPage, int dataLine);
SyncObject syncObject;
int32 sectionId;
@@ -89,7 +93,6 @@
Bitmap *freeLines;
short level;
SparseArray<int,100> sectionPages;
- static void redoBlobUpdate(Dbb* dbb, int32 locatorPage, int locatorLine, int32 dataPage,
int dataLine);
};
#endif // !defined(AFX_SECTION_H__6A019C25_A340_11D2_AB5A_0000C01D2301__INCLUDED_)
--- 1.26/storage/falcon/StorageTableShare.cpp 2007-05-19 16:52:56 -04:00
+++ 1.27/storage/falcon/StorageTableShare.cpp 2007-05-19 16:52:56 -04:00
@@ -493,3 +493,8 @@
if ( (storageDatabase = db) )
storageDatabase->addRef();
}
+
+uint64 StorageTableShare::estimateCardinality(void)
+{
+ return table->estimateCardinality();
+}
--- 1.27/storage/falcon/StorageTableShare.h 2007-05-19 16:52:56 -04:00
+++ 1.28/storage/falcon/StorageTableShare.h 2007-05-19 16:52:56 -04:00
@@ -130,6 +130,7 @@
int numberIndexes;
bool tempTable;
void setDatabase(StorageDatabase* db);
+ uint64 estimateCardinality(void);
};
#endif
--- 1.106/storage/falcon/Table.cpp 2007-05-19 16:52:56 -04:00
+++ 1.107/storage/falcon/Table.cpp 2007-05-19 16:52:56 -04:00
@@ -52,6 +52,7 @@
#include "Repository.h"
#include "Interlock.h"
#include "Collation.h"
+#include "Section.h"
#ifndef STORAGE_ENGINE
#include "Trigger.h"
@@ -780,6 +781,7 @@
recordBitmap = new Bitmap;
thawedBytes = 0;
thawedRecords = 0;
+ cardinality = 0;
}
Record* Table::fetch(int32 recordNumber)
@@ -3014,3 +3016,16 @@
return priorVersion->fetchVersion (trans);
}
***/
+
+int64 Table::estimateCardinality(void)
+{
+ if (cardinality)
+ return cardinality;
+
+ if (!dataSection)
+ dataSection = dbb->findSection(dataSectionId);
+
+ cardinality = dataSection->estimateCardinality();
+
+ return cardinality;
+}
--- 1.21/storage/falcon/Table.h 2007-05-19 16:52:56 -04:00
+++ 1.22/storage/falcon/Table.h 2007-05-19 16:52:56 -04:00
@@ -175,6 +175,7 @@
void validateAndInsert(Transaction *transaction, RecordVersion *record);
bool hasUncommittedRecords(Transaction* transaction);
void checkAncestor(Record* current, Record* oldRecord);
+ int64 estimateCardinality(void);
Record* fetchForUpdate(Transaction* transaction, Record* record);
RecordVersion* lockRecord(Record* record, Transaction* transaction);
@@ -213,6 +214,7 @@
Bitmap *recordBitmap;
Section *dataSection;
Section *blobSection;
+ uint64 cardinality;
int tableId;
int dataSectionId;
int blobSectionId;
@@ -231,6 +233,7 @@
protected:
const char *type;
+public:
};
#endif // !defined(AFX_TABLE_H__02AD6A42_A433_11D2_AB5B_0000C01D2301__INCLUDED_)
--- 1.86/storage/falcon/Transaction.cpp 2007-05-19 16:52:56 -04:00
+++ 1.87/storage/falcon/Transaction.cpp 2007-05-19 16:52:56 -04:00
@@ -260,6 +260,13 @@
Sync syncActiveTransactions(&transactionManager->activeTransactions.syncObject,
"Transaction::commit");
syncActiveTransactions.lock(Exclusive);
transactionManager->activeTransactions.remove(this);
+
+ for (RecordVersion *record = records; record; record = record->next)
+ if (!record->priorVersion)
+ ++record->table->cardinality;
+ else if (record->state == recDeleted)
+ --record->table->cardinality;
+
syncActiveTransactions.unlock();
}
--- 1.162/storage/falcon/ha_falcon.cpp 2007-05-19 16:52:56 -04:00
+++ 1.163/storage/falcon/ha_falcon.cpp 2007-05-19 16:52:56 -04:00
@@ -453,6 +453,7 @@
}
}
+ stats.records = (ha_rows) storageShare->estimateCardinality();
thr_lock_data_init((THR_LOCK *)storageShare->impure, &lockData, NULL);
setIndexes();
| Thread |
|---|
| • bk commit into 6.0-falcon tree (jas:1.2524) | U-ROWVWADEjas | 19 May |