oracle datetime精度,在Oracle中选择更高的时间戳精度有哪些缺点?

没有缺点,使用时间戳(9)如果有意义.

时间戳(9)和时间戳(1)使用相同的空间量,其性能相同.我只能找到一个有性能差异的情况,在这种情况下,时间戳(9)实际上比时间戳(1)快.

(我将为您省下许多无聊的代码,插入到时间戳(1)和时间戳(9)列中,并对其进行比较

对他们的操作.)

这表明它们使用相同的空间量(插入许多值并比较dba_segments):

--Create tables with timestamps and populate them with the same data (with different precision)

--Set initial and next to a low value so we can closely check the segment size)

create table timestamp1 (t1 timestamp(1), t2 timestamp(1), t3 timestamp(1), t4 timestamp(1), t5 timestamp(1))

storage(initial 65536 next 65536);

insert into timestamp1

select current_timestamp(1), current_timestamp(1), current_timestamp(1), current_timestamp(1), current_timestamp(1)

from dual connect by level <= 100000;

create table timestamp9 (t1 timestamp(9), t2 timestamp(9), t3 timestamp(9), t4 timestamp(9), t5 timestamp(9))

storage(initial 65536 next 65536);

insert into timestamp9

select current_timestamp(9), current_timestamp(9), current_timestamp(9), current_timestamp(9), current_timestamp(9)

from dual connect by level <= 100000;

--Segment size is identical

select segment_name, bytes from dba_segments where segment_name in ('TIMESTAMP1', 'TIMESTAMP9');

--SEGMENT_NAME BYTES

--TIMESTAMP1 8388608

--TIMESTAMP9 8388608

这是时间戳(9)在使用current_timestamp时更快,您可能需要在某些时候使用它来生成数据.但是我们只谈到我的慢桌面上大约0.175和0.25秒之间的差异来产生100K的时间戳.我不知道为什么时间戳(9)更快,也许时间戳总是生成为时间戳(9),然后四舍五入到其他精度?

--current_timestamp(9) is slightly faster than current_timestamp(1)

select count(*) from

(

select *

from dual

--where current_timestamp(9) = current_timestamp(9)

where current_timestamp(1) = current_timestamp(1)

connect by level <= 100000

);

编辑:性能差异存在于10g而不是11g.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值