【发布时间】:2011-03-05 08:48:51
【问题描述】:
当某些行具有空值时,我应该如何索引日期列? 我们必须在日期范围和具有空日期的行之间选择行。
我们使用 Oracle 9.2 及更高版本。
我找到的选项
- 在日期列上使用位图索引
- 使用日期列的索引和状态字段的索引,当日期为空时,其值为 1
- 在日期列和其他授予的非空列上使用索引
我对选项的想法是:
到 1:表有许多不同的值才能使用位图索引
到 2:我必须仅为此目的添加一个字段,并在我想检索空日期行时更改查询
到 3:将字段添加到并不真正需要的索引时会很棘手
这种情况的最佳做法是什么? 提前致谢
我读过的一些信息:
Oracle Date Index
When does Oracle index null column values?
编辑
我们的表有 300,000 条记录。每天插入和删除 1,000 到 10,000 条记录。 280,000 条记录的交付日期为空。它是一种拣货缓冲器。
我们的结构(翻译成英文)是:
create table orders
(
orderid VARCHAR2(6) not null,
customerid VARCHAR2(6) not null,
compartment VARCHAR2(8),
externalstorage NUMBER(1) default 0 not null,
created_at DATE not null,
last_update DATE not null,
latest_delivery DATE not null,
delivered_at DATE,
delivery_group VARCHAR2(9),
fast_order NUMBER(1) default 0 not null,
order_type NUMBER(1) default 0 not null,
produkt_group VARCHAR2(30)
)
【问题讨论】:
-
嗨,1 行有多少字节,有多少行/增长率是多少?
-
编辑后:如果 300,000 行中有 280,000 行包含空值,并且您想全部选择它们,为什么要索引空值?既然要读整本书,为什么还要按索引来读呢?
-
@Alexander:你的问题很重要。因为它,我分析了我应该首先做的数据。
标签: oracle optimization indexing null