Building Indexes Concurrently

/*
 * We do a concurrent index build by first inserting the catalog entry for the
 * index via index_create(), marking it not indisready and not indisvalid.
 * Then we commit our transaction and start a new one, then we wait for all
 * transactions that could have been modifying the table to terminate.	Now
 * we know that any subsequently-started transactions will see the index and
 * honor its constraints on HOT updates; so while existing HOT-chains might
 * be broken with respect to the index, no currently live tuple will have an
 * incompatible HOT update done to it.	We now build the index normally via
 * index_build(), while holding a weak lock that allows concurrent
 * insert/update/delete.  Also, we index only tuples that are valid
 * as of the start of the scan (see IndexBuildHeapScan), whereas a normal
 * build takes care to include recently-dead tuples.  This is OK because
 * we won't mark the index valid until all transactions that might be able
 * to see those tuples are gone.  The reason for doing that is to avoid
 * bogus unique-index failures due to concurrent UPDATEs (we might see
 * different versions of the same row as being valid when we pass over them,
 * if we used HeapTupleSatisfiesVacuum).  This leaves us with an index that
 * does not contain any tuples added to the table while we built the index.



 
  * For a concurrent build, it's important to make the catalog entries
  * visible to other transactions before we start to build the index. That
  * will prevent them from making incompatible HOT updates. The new index
  * will be marked not indisready and not indisvalid, so that no one else
  * tries to either insert into it or use it for queries.
 
 */
 


普通的create index是当建index时,不充许对表进行更改,postgresql支持的Concurrent创建index,是充分在建索引时同时对表进行更改。

共用了三个事务。

第一个事务,只是在系统表中增加索引定义,不建索引,索引不能insert ,也不能select

第二个事务,创建索引,创建过程中充许对表insert/update/delete,提交时,索引可以insert,不能select.

第三个事务,把第二个事务过程中,没加入索引中的,合并进索引。

 

 

http://www.postgresql.org/docs/9.1/static/sql-createindex.html#SQL-CREATEINDEX-CONCURRENTLY

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Idea shared indexes是一种通过共享索引来加强创意和思维的方法。该方法旨在促进团队成员之间的合作和交流,以获得更好的创新结果。 在传统的创意生成过程中,每个团队成员通常只能看到自己的创意和想法。然而,这种隔离的方式可能会限制创意的范围和质量。因此,在使用idea shared indexes之前,团队成员将创意和想法记录在共享的索引中,使其他成员能够看到并提供反馈和改进建议。 通过使用共享索引,团队成员能够互相学习和影响彼此的创意。这种开放和合作的环境可以激发创造力和想象力,同时也增加了创意的多样性和质量。团队成员可以从其他成员的思维过程中获得灵感,并从中发展出更好的创意。 Idea shared indexes还可以提高团队之间的沟通和合作。成员之间可以通过共享索引来交流想法,并通过评论和讨论来深入理解和发展创意。这种协作可以帮助团队成员共同解决问题,并找到最佳的解决方案。 此外,idea shared indexes还可以提高创意的迭代和持续改进。通过不断记录、摘录和分享创意,团队成员可以进一步改进和完善创意,并在每一次迭代中获得更好的结果。 综合而言,idea shared indexes是一种通过共享索引来加强创意和思维的方法。它提供了一个开放和合作的环境,促进团队成员之间的交流和合作,提高创意的多样性和质量,并促进创意的迭代和持续改进。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值