Question

I have loaded 150 million records into MonetDB. All data inserted into a single table. The table does not have any constraint(ex. UNIQUE, ..). I have not created any index myself. The original source CSV file is about 7.2 GB and after importing database is about 8GB. I ran a COUNT(*) with WHERE, it returned in 12 seconds. according to documentation:

The index statements in the SQL standard are recognized, but their implementation is different from competitive products. MonetDB/SQL interprets these statements as an advice and often freely neglects it, relying on its own decision to create and maintain indexes for fast access.

Now How can know that MonetDB has created index itself? I used EXPLAIN but I didn't understand the output: This is the actual query:

EXPLAIN SELECT COUNT(*) FROM vbvdata WHERE vbvdata_speed > 80 AND vbvdata_lane_id = 2;

and this is the EXPLAIN output:

+--------------------------------------------------------------------------------+
| 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()                                                         |
+--------------------------------------------------------------------------------+

Can anyone help?

Was it helpful?

Solution

In general you can not know when MonetDB creates/uses an index. This is determined dynamically based on each operator invocation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top