-[NSFetchRequest setFetchBatchSize:] で指定したサイズ値がフェッチ時に発行される SQLの LIMIT値となる。
例えば
[fetchRequest setFetchBatchSize:20];とするとSQLはこうなる。
SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZMODIFIEDDATE, t0.ZFEE, t0.ZMEMO, t0.ZCREATEDDATE, t0.ZOPERATEDDATE, t0.ZCUSTOMER FROM ZKARTE t0 WHERE t0.Z_PK IN (?,?,?) ORDER BY t0.ZOPERATEDDATE DESC LIMIT 20
3件ヒットするケースで、サイズを1とすると
[fetchRequest setFetchBatchSize:1];
こうなる。
sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZMODIFIEDDATE, t0.ZFEE, t0.ZMEMO, t0.ZCREATEDDATE, t0.ZOPERATEDDATE, t0.ZCUSTOMER FROM ZKARTE t0 WHERE t0.Z_PK IN (?) ORDER BY t0.ZOPERATEDDATE DESC LIMIT 1 sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZMODIFIEDDATE, t0.ZFEE, t0.ZMEMO, t0.ZCREATEDDATE, t0.ZOPERATEDDATE, t0.ZCUSTOMER FROM ZKARTE t0 WHERE t0.Z_PK IN (?) ORDER BY t0.ZOPERATEDDATE DESC LIMIT 1 sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZMODIFIEDDATE, t0.ZFEE, t0.ZMEMO, t0.ZCREATEDDATE, t0.ZOPERATEDDATE, t0.ZCUSTOMER FROM ZKARTE t0 WHERE t0.Z_PK IN (?) ORDER BY t0.ZOPERATEDDATE DESC LIMIT 1
LIMIT 1 のSQLが件数分(3件)発行される。
※iPhone OS 3.1.3 用コードで確認