关于数据库postgresql, delete 与 insert,create 的性能比较

在44w数据的固态硬盘上,创建数字索引用时288ms,而创建字符索引varchar(300)用时2s99ms。对于DELETE、INSERT操作,CREATE表耗时1s571ms,INSERT耗时6s308ms,而DELETE仅需517ms。在数据量不大或保留比例不高时,DELETE操作更优。
摘要由CSDN通过智能技术生成

关于数字索引与字符索引的性能比较
44w数据 固态硬盘:数字索引288ms,字符索 varchar(300)引 2 s 99 ms

 

hhy_event_fuse.public> create index tmp23_event_time_index
                           on tmp23 (event_time)
[2023-01-13 14:09:01] completed in 288 ms
hhy_event_fuse.public> create index tmp23format_index
                           on tmp23 (time_format)
[2023-01-13 14:09:04] completed in 2 s 99 ms


关于 delete 与 insert,create 的性能比较
create -->1 s 571 ms
insert -->6 s 308 ms
delete -->517 ms
所以在数据量不是很大,或者保留比不是很大(3kw保留50w)的情况下 该delete还是delete吧

hhy_event_fuse.public> create table tmp24 as select * from  ods_traffic_event_info  where time_format <'2023-01-03 00:00:00'
[2023-01-13 14:15:09] 444,269 rows affected in 1 s 571 ms

hhy_event_fuse.public> insert into tmp23 select * from ods_traffic_event_info where time_format <'2023-01-03 00:00:00'
[2023-01-13 14:11:17] 444,269 rows affected in 6 s 308 ms

hhy_event_fuse.public> delete  from tmp23 where time_format <'2023-01-03 00:00:00'
[2023-01-13 14:10:37] 444,269 rows affected in 517 ms

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值