有没有办法让以下代码执行得比现在快?所以真正的问题是:是否存在具有最佳性能的圣杯连接功能,还是这样呢?
我们在视图中使用连接函数4或5次,这会减慢查询速度。我们想知道我们是否可以加快速度,以便更快地检索搜索结果。它现在不慢,但速度会更快: - )
using System;
using System.Data.SqlTypes;
using System.IO;
using Microsoft.SqlServer.Server;
using System.Text;
[Serializable]
[SqlUserDefinedAggregate(Format.UserDefined, MaxByteSize = 8000)]
public struct Concatenate : IBinarySerialize
{
private StringBuilder value;
public void Init()
{
value = new StringBuilder(500);
}
public void Accumulate(SqlString input)
{
if (input != null)
{
this.value.Append(", ");
this.value.Append(input.Value);
}
}
public void Merge(Concatenate input)
{
this.value.Append(", ");
this.value.Append(input.value);
}
public SqlString Terminate()
{
if(value.Length > 2)
value.Remove(0, 2);
return new SqlString(value.ToString());
}
public void Read(BinaryReader r)
{
this.value = new StringBuilder(r.ReadString(), 500);
}
public void Write(BinaryWriter w)
{
w.Write(this.value.ToString());
}
}