index key compression 索引压缩对性能的影响

使用体验:

Oracle允许指定压缩列,全压 或者advanced compress。使用压缩的目的是减少IO的消耗。所以在明确创建索引列, 已经索引顺序后可以比较不同压缩方式被检索的数据块数。 从而找到最优的索引。索引列中如果很少有重复值,就没有必要使用压缩

例子:

-- when table has hug rows , by using parallel option is better to create index in short time.

CREATE INDEX index_name ON table_name (key_1,key_2,key_3,key_4) PARALLEL 24     TABLESPACE  ts_INDX ;

CREATE INDEX index_name ON table_name (key_1,key_2,key_3,key_4) PARALLEL 24   compress 1  TABLESPACE  ts_INDX ;

CREATE INDEX index_name ON table_name (key_1,key_2,key_3,Key_4) PARALLEL 24   compress 2 TABLESPACE  ts_INDX ;

CREATE INDEX index_name ON table_name (key_1,key_2,key_3,key_4) PARALLEL 24   compress  3 TABLESPACE  ts_INDX ;

CREATE INDEX index_name ON table_name (key_1,key_2,key_3,key_4) PARALLEL 24   compress  TABLESPACE  ts_INDX ;

exec dbms_stats.gather_index_stats(ownname => 'USER_NAME',indname => 'index_name' ,estimate_percent => 100 ,degree => 24) ; 
ALTER INDEX user_name.index_name NOPARALLEL; 

根据具体需求比较那种压缩更少的COST and execution time

select BYTES/1024/1024 mb, t.* from  DBA_segments  t where segment_name='index_name'  ;

select index_name, index_type, leaf_blocks, compression, t.* from dba_indexes t where index_name in('index_name')
and OWNER='user_name';
 

12c new feature: advanced high takes more times when creating index, but it has higher compression, which means hige compression make the index has smaller size and less leavef blocks. IO cost will be the loest one. the defects are maitaining time longer if the table doesn't have frequent DML, it will be good. 

compress advanced low: oracle use low cpu cost to get  the compression rate.

CREATE INDEX index_name ON table_name (key_1,key_2,key_3,key_4) PARALLEL 24   compress advanced low  TABLESPACE  ts_INDX ;

CREATE INDEX index_name ON table_name (key_1,key_2,key_3,key_4) PARALLEL 24   compress advanced high  TABLESPACE  ts_INDX ;

### 如何在 Unity 中进行网格压缩 #### 使用第三方插件或工具 对于希望简化工作流程的开发者来说,使用现成的解决方案可能是最有效的方式之一。例如,Asset Store 上有许多专门用于优化模型资源大小和性能表现的资产包,其中一些提供了强大的网格压缩功能[^1]。 #### 自定义脚本实现基本网格顶点焊接算法 如果倾向于自己动手编写逻辑来处理这个问题,则可以从简单的顶点焊接入手。下面是一个基于C#编写的简易版顶点合并函数: ```csharp using UnityEngine; public class MeshCompressor : MonoBehaviour { public float weldThreshold = 0.0001f; void Start() { var meshFilter = GetComponent<MeshFilter>(); if (meshFilter != null && meshFilter.sharedMesh != null){ Compress(meshFilter); } } private void Compress(MeshFilter filter) { List<Vector3> vertices = new List<Vector3>(filter.mesh.vertices); int[] triangles = filter.mesh.triangles; Dictionary<int, Vector3> uniqueVertices = new Dictionary<int, Vector3>(); for(int i=0;i<vertices.Count;++i){ bool foundMatch=false; foreach(var kvp in uniqueVertices.ToList()){ if(Vector3.Distance(vertices[i],kvp.Value)<weldThreshold){ // Replace all occurrences of current vertex index with matched one. Array.ForEach(triangles,(ref int t)=>{if(t==i)t=kvp.Key;}); foundMatch=true; break; } } if(!foundMatch) uniqueVertices.Add(i,vertices[i]); } // Rebuild the compressed mesh data structure here... Debug.Log($"Original Vertices Count:{vertices.Count}, After Compression:{uniqueVertices.Keys.Max()+1}"); } } ``` 此代码片段展示了如何遍历原始网格中的每一个顶点,并尝试查找距离小于给定阈值`weldThreshold`的其他顶点;一旦发现符合条件的情况就将其索引替换掉,从而减少冗余的数据量。不过需要注意的是这只是一个非常基础的例子,在实际应用当中可能还需要考虑更多因素比如法线方向一致性等问题[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值