我已经在MonetDB中加载了1.5亿条记录。所有数据都插入到一个表中。该表没有任何约束(例如UNIQUE
,..)。我自己没有创建任何索引。原始源CSV文件大约为7.2 GB,导入数据库后大约为8 GB。我用COUNT(*)
运行WHERE
,它在12秒后返回。根据文件:
SQL标准中的索引语句被识别,但是它们是 实施不同于竞争产品。 MonetDB / SQL 将这些陈述解释为建议并经常自由地忽略它, 依靠自己的决定快速创建和维护索引 访问。
现在怎么知道MonetDB自己创建了索引?我使用EXPLAIN
但我不理解输出:
这是实际查询:
EXPLAIN SELECT COUNT(*) FROM vbvdata WHERE vbvdata_speed > 80 AND vbvdata_lane_id = 2;
这是EXPLAIN
输出:
+--------------------------------------------------------------------------------+
| mal |
+================================================================================+
| function user.s11_1{autoCommit=true}(A0:bte,A1:bte):void; |
| X_4 := sql.mvc(); |
| X_46:bat[:oid,:bte] := sql.bind(X_4,"sys","vbvdata","vbvdata_speed",0); |
| X_38:bat[:oid,:bte] := sql.bind(X_4,"sys","vbvdata","vbvdata_speed",2); |
| X_48 := algebra.kdifference(X_46,X_38); |
| X_49 := algebra.kunion(X_48,X_38); |
| X_32:bat[:oid,:bte] := sql.bind(X_4,"sys","vbvdata","vbvdata_speed",1); |
| X_50 := algebra.kunion(X_49,X_32); |
| X_18:bat[:oid,:oid] := sql.bind_dbat(X_4,"sys","vbvdata",1); |
| X_19 := bat.reverse(X_18); |
| X_51 := algebra.kdifference(X_50,X_19); |
| X_25:bat[:oid,:bte] := sql.bind(X_4,"sys","vbvdata","vbvdata_lane_id",0); |
| X_27 := algebra.uselect(X_25,A1); |
| X_23:bat[:oid,:bte] := sql.bind(X_4,"sys","vbvdata","vbvdata_lane_id",2); |
| X_28 := algebra.kdifference(X_27,X_23); |
| X_24 := algebra.uselect(X_23,A1); |
| X_29 := algebra.kunion(X_28,X_24); |
| X_21:bat[:oid,:bte] := sql.bind(X_4,"sys","vbvdata","vbvdata_lane_id",1); |
| X_22 := algebra.uselect(X_21,A1); |
| X_30 := algebra.kunion(X_29,X_22); |
| X_31 := algebra.kdifference(X_30,X_19); |
| X_52 := algebra.semijoin(X_51,X_31); |
| X_53 := algebra.thetauselect(X_52,A0,">"); |
| X_55 := algebra.kdifference(X_53,X_38); |
| X_41 := algebra.semijoin(X_38,X_31); |
| X_42 := algebra.thetauselect(X_41,A0,">"); |
| X_56 := algebra.kunion(X_55,X_42); |
| X_35 := algebra.semijoin(X_32,X_31); |
| X_36 := algebra.thetauselect(X_35,A0,">"); |
| X_57 := algebra.kunion(X_56,X_36); |
| X_58 := algebra.kdifference(X_57,X_19); |
| X_59 := algebra.markT(X_58,0@0:oid); |
| X_60 := bat.reverse(X_59); |
| X_12:bat[:oid,:lng] := sql.bind(X_4,"sys","vbvdata","vbvdata_id",0); |
| X_10:bat[:oid,:lng] := sql.bind(X_4,"sys","vbvdata","vbvdata_id",2); |
| X_14 := algebra.kdifference(X_12,X_10); |
| X_15 := algebra.kunion(X_14,X_10); |
| X_6:bat[:oid,:lng] := sql.bind(X_4,"sys","vbvdata","vbvdata_id",1); |
| X_16 := algebra.kunion(X_15,X_6); |
| X_61 := algebra.leftjoin(X_60,X_16); |
| X_62 := aggr.count(X_61); |
| sql.exportValue(1,"sys.vbvdata","L1":str,"wrd",64,0,6,X_62,""); |
| end s11_1; |
| # optimizer.mitosis() |
| # optimizer.dataflow() |
+--------------------------------------------------------------------------------+
有人可以帮忙吗?
答案 0 :(得分:3)
通常,您无法知道MonetDB何时创建/使用索引。这是根据每个操作员调用动态确定的。