在Oracle中选择更高的时间戳精度有哪些缺点?
发布时间:2020-12-12 13:04:28 所属栏目:百科 来源:网络整理
导读:Oracle允许在表中指定TIMESTAMP类型的精度 – SECOND datetime字段的小数部分中的位数.有没有指定最大精度TIMESTAMP(9)的缺点? 我可以想到的一个原因是这些信息可能被Oracle工具用于更漂亮的输出. 最多9位数字表示该字段存储为4字节整数,因此不应有任何性能
Oracle允许在表中指定TIMESTAMP类型的精度 – SECOND datetime字段的小数部分中的位数.有没有指定最大精度TIMESTAMP(9)的缺点?
我可以想到的一个原因是这些信息可能被Oracle工具用于更漂亮的输出. 最多9位数字表示该字段存储为4字节整数,因此不应有任何性能影响,请在此处错误更正. 没有缺点,使用时间戳(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) 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) 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. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |