CoreData: sql:
SELECT t0.Z_ENT, t0.Z_PK, t0.Z_OPT, t0.ZCLIENTCREATEDAT, t0.ZCLIENTUPDATEDAT, t0.ZCREATEDAT, t0.ZDATERAISED, t0.ZID, t0.ZLOCKVERSION, t0.ZNAME, t0.ZSEQUENCENUMBER, t0.ZTYPE, t0.ZUPDATEDAT, t0.ZUUID, t0.ZVSYNCSTATUS, t0.ZVVERSION, t0.ZVVERSIONSTATUS, t0.ZCREATEDBY, t0.ZDATA, t0.ZOWNEDBY, t0.ZPROJECT, t0.ZPROJECTCOMPANY, t0.ZTEMPLATE, t0.ZWBSITEM, t0.ZACTIONTYPE, t0.ZSTATUS, t0.ZCOMPANY, t0.ZCLOSEDREASON, t0.ZDOCUMENTDATA, t0.ZSMARKWHENREADYTOSEND, t0.ZSPDFSYNCSTATUS, t0.ZSTATUS1, t0.ZAUTHORISATIONCODE, t0.ZBCCRECEIVED, t0.ZRECIPIENTEMAIL, t0.ZRECIPIENTNAME, t0.ZRFIRESPONSESTATUS
FROM ZBASEFORM t0
WHERE ((( t0.ZVVERSIONSTATUS = ? OR ( t0.ZVVERSIONSTATUS = ? AND t0.ZVSYNCSTATUS = ?) OR ( t0.ZVVERSIONSTATUS = ? AND t0.ZVSYNCSTATUS = ?)) AND t0.ZPROJECT = ?) AND t0.Z_ENT = ?)
ORDER BY t0.ZDATERAISED DESC, t0.ZCLIENTCREATEDAT DESC
CoreData: annotation: sql connection fetch time: 1.7336s
CoreData: annotation: total fetch execution time: 1.7462s for 1868 rows.
该表只有1975行,我要提取其中的1868行。
我将数据库从设备复制到桌面,然后执行
sqlite> EXPLAIN SELECT ...
并得到了这个野兽。addr opcode p1 p2 p3 p4 p5 comment
---- ------------- ---- ---- ---- ------------- -- -------------
0 Init 0 105 0 00
1 SorterOpen 1 40 0 k(2,-B,-B) 00
2 OpenRead 0 8 0 37 00
3 OpenRead 2 76 0 k(2,,) 02
4 Integer 7 1 0 00
5 SeekGE 2 60 1 1 00
6 IdxGT 2 60 1 1 00
7 Seek 2 0 0 00
8 Column 0 8 2 00
9 Eq 3 16 2 (BINARY) 44
10 Ne 5 13 2 (BINARY) 54
11 Column 0 6 4 00
12 Eq 6 16 4 (BINARY) 44
13 Ne 5 59 2 (BINARY) 54
14 Column 0 6 4 00
15 Ne 7 59 4 (BINARY) 54
16 Column 0 12 4 00
17 Ne 8 59 4 (BINARY) 54
18 Column 2 0 11 00
19 IdxRowid 2 12 0 00
20 Column 0 2 13 00
21 Column 0 24 14 00
22 Column 0 25 15 00
23 Column 0 26 16 00
24 Column 0 27 17 00
25 Column 0 3 18 00
26 Column 0 4 19 00
27 Column 0 29 20 00
28 Column 0 5 21 00
29 Column 0 30 22 00
30 Column 0 28 23 00
31 Column 0 31 24 00
32 Column 0 6 25 00
33 Column 0 7 26 00
34 Column 0 8 27 00
35 Column 0 9 28 00
36 Column 0 10 29 00
37 Column 0 11 30 00
38 Column 0 12 31 00
39 Column 0 13 32 00
40 Column 0 14 33 00
41 Column 0 15 34 00
42 Column 0 32 35 00
43 Column 0 16 36 00
44 Column 0 17 37 00
45 Column 0 18 38 00
46 Column 0 36 39 00
47 Column 0 19 40 00
48 Column 0 20 41 00
49 Column 0 21 42 00
50 Column 0 33 43 00
51 Column 0 22 44 00
52 Column 0 34 45 00
53 Column 0 35 46 00
54 Column 0 23 47 00
55 Copy 17 9 0 00
56 Copy 14 10 0 00
57 MakeRecord 9 39 48 00
58 SorterInsert 1 48 0 00
59 Next 2 6 1 00
60 Close 0 0 0 00
61 Close 2 0 0 00
62 OpenPseudo 3 49 40 00
63 SorterSort 1 104 0 00
64 SorterData 1 49 3 00
65 Column 3 2 11 00
66 Column 3 3 12 00
67 Column 3 4 13 00
68 Column 3 5 14 00
69 Column 3 6 15 00
70 Column 3 7 16 00
71 Column 3 8 17 00
72 Column 3 9 18 00
73 Column 3 10 19 00
74 Column 3 11 20 00
75 Column 3 12 21 00
76 Column 3 13 22 00
77 Column 3 14 23 00
78 Column 3 15 24 00
79 Column 3 16 25 00
80 Column 3 17 26 00
81 Column 3 18 27 00
82 Column 3 19 28 00
83 Column 3 20 29 00
84 Column 3 21 30 00
85 Column 3 22 31 00
86 Column 3 23 32 00
87 Column 3 24 33 00
88 Column 3 25 34 00
89 Column 3 26 35 00
90 Column 3 27 36 00
91 Column 3 28 37 00
92 Column 3 29 38 00
93 Column 3 30 39 00
94 Column 3 31 40 00
95 Column 3 32 41 00
96 Column 3 33 42 00
97 Column 3 34 43 00
98 Column 3 35 44 00
99 Column 3 36 45 00
100 Column 3 37 46 00
101 Column 3 38 47 00
102 ResultRow 11 37 0 00
103 SorterNext 1 64 0 00
104 Halt 0 0 0 00
105 Transaction 0 0 188 0 01
106 TableLock 0 8 0 ZBASEFORM 00
107 Integer 1 3 0 00
108 Integer 2 5 0 00
109 Integer 4 6 0 00
110 Integer 5 7 0 00
111 Integer 3 8 0 00
112 Goto 0 1 0 00
最佳答案
我找出了速度缓慢的原因。
对象属性之一是NSData blob,它显然完全杀死了CoreData中的访存排序。所以要当心。
关于ios - 为什么此CoreData提取如此缓慢?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45093710/