解决issue -- 列存加唯一索引插100万数据慢问题
This commit is contained in:
@ -383,49 +383,7 @@ bool CStoreAllocator::ColSpaceCacheExist(const CFileNode* cnodes, int nColumn)
|
||||
|
||||
LWLockRelease(CStoreColspaceCacheLock);
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* science we loose lock after get max cuid we will doubt the max cuid system
|
||||
* here we recheck max cuid located in index
|
||||
* we want to make sure if there is on another larger cuid in index
|
||||
*/
|
||||
uint32 CStoreAllocator::recheck_max_cuid(Relation m_rel, uint32 max_cuid, int index_num, Relation* m_idxRelation)
|
||||
{
|
||||
bool find = false;
|
||||
List* index_rel_list = NIL;
|
||||
|
||||
for (int i = 0; i < index_num; ++i) {
|
||||
Oid am_oid = m_idxRelation[i]->rd_rel->relam;
|
||||
if (am_oid == CBTREE_AM_OID || am_oid == CGIN_AM_OID) {
|
||||
index_rel_list = lappend(index_rel_list, m_idxRelation[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (list_length(index_rel_list) == 0) {
|
||||
return max_cuid;
|
||||
}
|
||||
uint32 max_idx_cuid = CStore::GetMaxIndexCUID(m_rel, index_rel_list) + 1;
|
||||
list_free_ext(index_rel_list);
|
||||
|
||||
if (max_idx_cuid == MaxCUID) {
|
||||
ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
|
||||
errmsg("No CUID is left for new CU in relation \"%u\".", m_rel->rd_id)));
|
||||
}
|
||||
|
||||
if (max_idx_cuid > max_cuid) {
|
||||
CStoreColFileDesc* entry = NULL;
|
||||
CStoreColumnFileTag tag(m_rel->rd_node, VirtualSpaceCacheColID, MAIN_FORKNUM);
|
||||
(void)LWLockAcquire(CStoreColspaceCacheLock, LW_EXCLUSIVE);
|
||||
entry = (CStoreColFileDesc*)hash_search(CStoreColspaceCache, (void*)&tag, HASH_FIND, &find);
|
||||
Assert(find);
|
||||
entry->maxCuid = max_idx_cuid + 1;
|
||||
LWLockRelease(CStoreColspaceCacheLock);
|
||||
return max_idx_cuid;
|
||||
}
|
||||
return max_cuid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CStoreFreeSpace::Initialize(int maxSize)
|
||||
{
|
||||
|
@ -1341,10 +1341,7 @@ void CStoreInsert::SaveAll(int options, _in_ const char* delBitmap)
|
||||
/* step 1: Lock relation for extension */
|
||||
LockRelationForExtension(m_relation, ExclusiveLock);
|
||||
uint32 curCUID = CStoreAllocator::GetNextCUID(m_relation);
|
||||
if (m_resultRelInfo != NULL && m_resultRelInfo->ri_NumIndices > 0) {
|
||||
curCUID = CStoreAllocator::recheck_max_cuid(
|
||||
m_relation, curCUID, m_resultRelInfo->ri_NumIndices, m_idxRelation);
|
||||
}
|
||||
|
||||
for (col = 0; col < attno; ++col) {
|
||||
if (m_relation->rd_att->attrs[col]->attisdropped)
|
||||
continue;
|
||||
|
@ -133,7 +133,6 @@ public:
|
||||
|
||||
static uint64 GetExtendOffset(uint64 max_offset);
|
||||
static uint32 CalcExtendSize(uint64 cu_offset, uint32 cu_size, uint64 extend_offset);
|
||||
static uint32 recheck_max_cuid(Relation m_rel, uint32 max_cuid, int index_num, Relation* m_idxRelation);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user