12
返回列表 发新帖
楼主: bisal

[讨论] 分区表和索引

[复制链接]
论坛徽章:
7
茶鸡蛋
日期:2013-06-14 13:16:17优秀写手
日期:2013-12-18 09:29:112014年新春福章
日期:2014-02-18 16:42:02马上有房
日期:2014-02-18 16:42:022015年新春福章
日期:2015-03-04 14:51:122015年新春福章
日期:2015-03-06 11:57:31ITPUB社区OCM联盟徽章
日期:2016-07-13 18:10:08
11#
 楼主| 发表于 2015-2-28 08:24 | 只看该作者
Yong Huang 发表于 2015-2-28 00:43
> 实际使用id的场景大多是若干表之间关联的情况,那这种(id,date)的复合主键是否有问题呢?

A query can ...

但这种场景下除了where a.id = b.id,一般是不是还需要带有date分区键作为条件?否则就是跨分区检索?

使用道具 举报

回复
论坛徽章:
7
茶鸡蛋
日期:2013-06-14 13:16:17优秀写手
日期:2013-12-18 09:29:112014年新春福章
日期:2014-02-18 16:42:02马上有房
日期:2014-02-18 16:42:022015年新春福章
日期:2015-03-04 14:51:122015年新春福章
日期:2015-03-06 11:57:31ITPUB社区OCM联盟徽章
日期:2016-07-13 18:10:08
12#
 楼主| 发表于 2015-2-28 08:45 | 只看该作者
Yong Huang 发表于 2015-2-28 00:43
> 实际使用id的场景大多是若干表之间关联的情况,那这种(id,date)的复合主键是否有问题呢?

A query can ...

我看Oracle官方文档中说:
“Index Performance Considerations
As you decide which type of index to use, consider that indexes rank in performance in the following order:
    Unique and local index
    Unique and global index
    All other non-unique indexes (normal, bitmap, function-based) and local index.”
优先选择的还是唯一索引,如果需求上必须有全局非唯一索引,是否效率上不会比不分区好呢?

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
13#
发表于 2015-3-2 23:37 | 只看该作者
> 这种场景下除了where a.id = b.id,一般是不是还需要带有date分区键作为条件?否则就是跨分区检索?

Correct. Only referencing the starting columns will use the index, but for partition elimination to work, that's not enough. You have to reference all columns in the partitioning key.

> 优先选择的还是唯一索引,如果需求上必须有全局非唯一索引,是否效率上不会比不分区好呢?

I'm sure the best answer is from your own test. Theoretically, a unique local index is as good as it can be. But it has its own problem. Imagine the overhead of checking for uniqueness every time a new row is inserted. The check is quick because it uses the unique index itself. But nonetheless, it's overhead (especially when the index is composite) compared to not checking at all in case of a non-unique index.

使用道具 举报

回复
论坛徽章:
7
茶鸡蛋
日期:2013-06-14 13:16:17优秀写手
日期:2013-12-18 09:29:112014年新春福章
日期:2014-02-18 16:42:02马上有房
日期:2014-02-18 16:42:022015年新春福章
日期:2015-03-04 14:51:122015年新春福章
日期:2015-03-06 11:57:31ITPUB社区OCM联盟徽章
日期:2016-07-13 18:10:08
14#
 楼主| 发表于 2015-3-3 08:58 | 只看该作者
Yong Huang 发表于 2015-3-2 23:37
> 这种场景下除了where a.id = b.id,一般是不是还需要带有date分区键作为条件?否则就是跨分区检索?

C ...

谢谢您。

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表