由于 mssql 限制为 900 字节,我需要减少索引大小。
我有一个类,它有一个声明为集合的集合。因此,主键由包括外键在内的所有非空列组成。从此主键创建一个索引。我不需要索引覆盖所有这些列。
有没有办法在不改变整个数据结构设置的情况下减小索引大小?
这是周围类定义中集合的当前配置:
<set cascade="save-update,persist,merge,refresh,replicate,evict,delete,delete-orphan" fetch="select" lazy="true" table="mySubsetTable" batch-size="1000" name="attributes">
<key foreign-key="FK_Mothertable">
<column name="number"/>
<column name="data"/>
</key>
<composite-element class="MySubsetElement">
<property name="type" length="200" not-null="true" type="class"/>
<property name="attribute" length="2000" column="attrValue" not-null="false"/>
<property name="myboolean" type="boolean">
<column name="myboolean"/>
</property>
<property name="anotherAttribute" length="200"/>
<property name="evenAnotherAttribute" length="200" not-null="true"/>
<property name="evenOneMoreAttribute" not-null="true">
<type name="SomeClass">
<param name="enumClass">someEnumClass</param>
</type>
</property>
</composite-element>
</set>
我目前正在使用带有 xdoclet 注释的休眠 3.3.1:
/**
* Attributes of this matchable
*
* @hibernate.set table="mySubsetTable" cascade="save-update,persist,merge,refresh,replicate,evict,delete,delete-orphan" lazy="true"
* batch-size="1000" fetch="select"
* @hibernate.key foreign-key="FK_Mothertable"
* @hibernate.key-column name="number"
* @hibernate.key-column name="data"
* @hibernate.composite-element class="MySubsetElement"
*/
public Set<MySubsetElement> getSubsetElements() { ... }
非常感谢您的建议!
(请不要让我参考http://docs.jboss.org/hibernate/ 我已经找到了这个。)
编辑 我不能减小所有属性的大小以适应大小限制。由外键组成的索引就足够了。此外,我真的很想要一个不会改变底层数据结构的解决方案,因为我正在开发一个已经在使用的产品。