我已经将 1.5 亿条记录加载到 MonetDB 中。插入到单个表中的所有数据。该表没有任何约束(例如UNIQUE
,..)。我自己没有创建任何索引。原始源 CSV 文件约为 7.2 GB,导入数据库后约为 8 GB。我跑了一个COUNT(*)
with 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() |
+--------------------------------------------------------------------------------+
任何人都可以帮忙吗?