とリポジトリがありoriginal
、premium
両方にインデックスを追加しようとしました。
public void SetupIndices()
{
original.Ext().Configure().ObjectClass(typeof(LineItem)).ObjectField("idField").Indexed(true);
original.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(LineItem), "idField"));
original.Ext().Configure().ObjectClass(typeof(LineItem)).ObjectField("nameField").Indexed(true);
original.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(LineItem), "nameField"));
original.Ext().Configure().ObjectClass(typeof(Order)).ObjectField("idField").Indexed(true);
original.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(Order), "idField"));
original.Ext().Configure().ObjectClass(typeof(Order)).ObjectField("nameField").Indexed(true);
original.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(Order), "nameField"));
original.Ext().Configure().ObjectClass(typeof(Creative)).ObjectField("idField").Indexed(true);
original.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(Creative), "idField"));
original.Ext().Configure().ObjectClass(typeof(Creative)).ObjectField("nameField").Indexed(true);
original.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(Creative), "nameField"));
original.Ext().Configure().ObjectClass(typeof(Company)).ObjectField("idField").Indexed(true);
original.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(Company), "idField"));
original.Ext().Configure().ObjectClass(typeof(Company)).ObjectField("nameField").Indexed(true);
original.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(Company), "nameField"));
original.Ext().Configure().ObjectClass(typeof(LineItemCreativeAssociation)).ObjectField("lineItemIdField").Indexed(true);
original.Ext().Configure().ObjectClass(typeof(LineItemCreativeAssociation)).ObjectField("creativeIdField").Indexed(true);
original.Commit();
premium.Ext().Configure().ObjectClass(typeof(LineItem)).ObjectField("idField").Indexed(true);
premium.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(LineItem), "idField"));
premium.Ext().Configure().ObjectClass(typeof(LineItem)).ObjectField("nameField").Indexed(true);
premium.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(LineItem), "nameField"));
premium.Ext().Configure().ObjectClass(typeof(Order)).ObjectField("idField").Indexed(true);
premium.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(Order), "idField"));
premium.Ext().Configure().ObjectClass(typeof(Order)).ObjectField("nameField").Indexed(true);
premium.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(Order), "nameField"));
premium.Ext().Configure().ObjectClass(typeof(Creative)).ObjectField("idField").Indexed(true);
premium.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(Creative), "idField"));
premium.Ext().Configure().ObjectClass(typeof(Creative)).ObjectField("nameField").Indexed(true);
premium.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(Creative), "nameField"));
premium.Ext().Configure().ObjectClass(typeof(Company)).ObjectField("idField").Indexed(true);
premium.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(Company), "idField"));
premium.Ext().Configure().ObjectClass(typeof(Company)).ObjectField("nameField").Indexed(true);
premium.Ext().Configure().Add(new UniqueFieldValueConstraint(typeof(Company), "nameField"));
premium.Ext().Configure().ObjectClass(typeof(LineItemCreativeAssociation)).ObjectField("lineItemIdField").Indexed(true);
premium.Ext().Configure().ObjectClass(typeof(LineItemCreativeAssociation)).ObjectField("creativeIdField").Indexed(true);
premium.Commit();
}
問題は、このクエリには時間がかかり、数百から数千の結果しか得られないことです。どのオブジェクト ストアにも 40,000 を超えるアイテムが含まれないようにする必要があります。私は何を間違っていますか?
var creatives = from Creative c in original.Query<Creative>()
join Company co in original.Query<Company>()
on c.advertiserId equals co.id
join LineItemCreativeAssociation lica in original.Query<LineItemCreativeAssociation>()
on c.id equals lica.creativeId
join LineItem li in original.Query<LineItem>()
on lica.lineItemId equals li.id
join LineItem newLI in premium.Query<LineItem>()
on li.name equals newLI.name
join Company newCO in premium.Query<Company>()
on co.name equals newCO.name
from Creative newC in premium.Query<Creative>()
.Where(o=>o.name == c.name).DefaultIfEmpty()
where newC == null
select new { creative = c, newCompany = newCO };