2012-04-05 5 views
0

私はNSPredicate NSPredicateのもパフォーマンス、非常に遅い

のように見えるNSPredicadeを持っている*述語= [NSPredicate predicateWithFormat:@ "((strasse.checksがYES [CD]を含みます)AND(raumattribute.schalterはCONTAINS [CD] YES )(または、(strasse.standort.ortcheck CONTAINS [CD] YES)AND(raumattribute.schalter CONTAINS [cd] YES) (strasse.checks CONTAINS [CD] NO))];または(strasse.checks CONTAINS [CD] NO)

しかし、パフォーマンスは非常に遅いです。それをより簡単かつ迅速にする方法はありますか?

+0

ですinteger/booleanの代わりに文字列属性を使う特別な理由はありますか? 'strasse.checks'、' raumattribute.schalter'、 'strasse.standort.ortcheck'にはどのような値がありますか? –

+0

strasse.checks、raumattribute.schalter、strasse.standort.ortcheckはブール値のNSSetです – Bashud

+0

どのように述語を実行しますか?フェッチ要求またはオブジェクトの配列?その配列はどこにありますか? –

答えて

0

まず、あなたはこのように見えるためにあなたの述語を簡略化することができます。

NSPredicate *predicate = 
[NSPredicate predicateWithFormat: 
@"(raumattribute.schalter CONTAINS YES OR raumattribute.schalter CONTAINS NO) AND \ 
(strasse.checks CONTAINS YES OR strasse.standort.ortcheck CONTAINS YES) OR \ 
strasse.standort.ortcheck CONTAINS NO"]; 

をその後、我々はraumattribute.schalterstrasse.standort.ortcheckだけブール値が含まれていると仮定した場合、我々は再び述語を簡略化することができます。

NSPredicate *predicate = 
[NSPredicate predicateWithFormat: 
@"[email protected] > 0 AND \ 
(strasse.checks CONTAINS YES OR [email protected] > 0) OR \ 
strasse.standort.ortcheck CONTAINS NO"]; 
+0

私が最初に単純化しようとすると、述語は何もフィルタリングしません。 2番目のxcodeを試すと、例外がスローされます:サポートされていない関数式raumattribute.schalter [SIZE] – Bashud

+0

'[SIZE]'を '@ count'に置き換えました。私はそれが例外を解決すべきだと思う。 –

関連する問題