Closed arjunsk closed 7 months ago
tbl
with index table join
.NormalizeL2
use sync.Pool
for allocating temporary output array.with index
and without index
.Old QPS | New QPS | |
---|---|---|
Without Index without PK | 1 | 11.97 |
With Index without PK | 4 | 12.62 |
Without Index with PK | NA | 1.9 |
With Index with PK | NA | 23.39 |
mysql> explain analyze SELECT a FROM t3 ORDER BY l2_distance(b,'[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]') ASC LIMIT 100;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project |
| Analyze: timeConsumed=0ms waitTime=47ms inputRows=100 outputRows=100 InputSize=400bytes OutputSize=400bytes MemorySize=400bytes |
| -> Sort |
| Analyze: timeConsumed=3ms waitTime=94ms inputRows=0 outputRows=100 InputSize=0bytes OutputSize=400bytes MemorySize=23568bytes |
| Sort Key: l2_distance(t3.b, cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32)) ASC |
| Limit: 100 |
| -> Join |
| Analyze: timeConsumed=0ms waitTime=530ms inputRows=3592 outputRows=1796 InputSize=977024bytes OutputSize=969840bytes MemorySize=0bytes |
| Join Type: INDEX |
| Join Cond: (t3.a = __mo_index_secondary_018e7992-4272-7901-9f21-92e187264b55.__mo_index_pri_col) |
| Runtime Filter Build: #[-1,0] |
| -> Table Scan on a.t3 |
| Analyze: timeConsumed=206ms scan_time=[total=206ms,min=8ms,max=33ms,dop=10] filter_time=[total=0ms,min=0ms,max=0ms,dop=10] waitTime=33ms inputRows=1796 outputRows=1796 InputSize=969840bytes OutputSize=969840bytes MemorySize=1033196bytes |
| Runtime Filter Probe: t3.a |
| -> Join |
| Analyze: timeConsumed=7ms probe_time=[total=7ms,min=0ms,max=0ms,dop=10] build_time=[0ms] waitTime=121ms inputRows=1000001 outputRows=1796 InputSize=11mb OutputSize=7184bytes MemorySize=180859bytes |
| Join Type: INNER |
| Join Cond: (__mo_index_secondary_018e7992-4272-7901-9f21-92e187264b55.__mo_index_centroid_fk_id = __mo_index_secondary_018e7992-4272-7d67-9ea5-771619ffa993.__mo_index_centroid_id) |
| -> Join |
| Analyze: timeConsumed=11ms probe_time=[total=11ms,min=0ms,max=1ms,dop=10] build_time=[0ms] waitTime=113ms inputRows=1000001 outputRows=1000000 InputSize=19mb OutputSize=11mb MemorySize=180875bytes |
| Join Type: SINGLE |
| Join Cond: (__mo_index_secondary_018e7992-4272-7901-9f21-92e187264b55.__mo_index_centroid_fk_version = cast(__mo_index_secondary_018e7992-4272-7711-a386-bcb4acce2407.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018e7992-4272-7901-9f21-92e187264b55 |
| Analyze: timeConsumed=78ms scan_time=[total=78ms,min=8ms,max=10ms,dop=8] waitTime=8ms inputRows=1000000 outputRows=1000000 InputSize=19mb OutputSize=19mb MemorySize=2mb |
| -> Table Scan on a.__mo_index_secondary_018e7992-4272-7711-a386-bcb4acce2407 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7992-4272-7711-a386-bcb4acce2407.__mo_index_key = 'version') |
| -> Sort |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=1 InputSize=0bytes OutputSize=8bytes MemorySize=4016bytes |
| Sort Key: l2_distance(__mo_index_secondary_018e7992-4272-7d67-9ea5-771619ffa993.__mo_index_centroid, normalize_l2(cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32))) ASC |
| Limit: CASE WHEN (@probe_limit IS NULL) THEN 1 ELSE cast(@probe_limit AS BIGINT) END |
| -> Join |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=500 InputSize=24bytes OutputSize=272000bytes MemorySize=32906bytes |
| Join Type: SINGLE |
| Join Cond: (__mo_index_secondary_018e7992-4272-7d67-9ea5-771619ffa993.__mo_index_centroid_version = cast(__mo_index_secondary_018e7992-4272-7711-a386-bcb4acce2407.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018e7992-4272-7d67-9ea5-771619ffa993 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=500 outputRows=500 InputSize=276000bytes OutputSize=276000bytes MemorySize=552000bytes |
| -> Table Scan on a.__mo_index_secondary_018e7992-4272-7711-a386-bcb4acce2407 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7992-4272-7711-a386-bcb4acce2407.__mo_index_key = 'version') |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
40 rows in set (0.05 sec)
mysql> explain analyze SELECT a FROM t3 ORDER BY l2_distance(b,'[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]') ASC LIMIT 100;
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project |
| Analyze: timeConsumed=0ms waitTime=105ms inputRows=100 outputRows=100 InputSize=400bytes OutputSize=400bytes MemorySize=400bytes |
| -> Sort |
| Analyze: timeConsumed=192ms waitTime=210ms inputRows=0 outputRows=100 InputSize=0bytes OutputSize=400bytes MemorySize=7mb |
| Sort Key: l2_distance(t3.b, cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32)) ASC |
| Limit: 100 |
| -> Table Scan on a.t3 |
| Analyze: timeConsumed=664ms scan_time=[total=664ms,min=62ms,max=86ms,dop=9] waitTime=0ms inputRows=1000000 outputRows=1000000 InputSize=514mb OutputSize=514mb MemorySize=75mb |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
8 rows in set (0.11 sec)
QUERY PLAN |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Limit (cost=350.00..351.29 rows=100 width=12) |
-> Index Scan using idx3 on t3 (cost=350.00..13262.00 rows=1000000 width=12) |
Order By: (b <=> '[1,3,11,110,62,22,4,0,43,21,22,18,6,28,64,9,11,1,0,0,1,40,101,21,20,2,4,2,2,9,18,35,1,1,7,25,108,116,63,2,0,0,11,74,40,101,116,3,33,1,1,11,14,18,116,116,68,12,5,4,2,2,9,102,17,3,10,18,8,15,67,63,15,0,14,116,80,0,2,22,96,37,28,88,|
QUERY PLAN |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Limit (cost=94603.74..94615.41 rows=100 width=12) |
-> Gather Merge (cost=94603.74..191832.83 rows=833334 width=12) |
Workers Planned: 2 |
-> Sort (cost=93603.71..94645.38 rows=416667 width=12) |
Sort Key: ((b <=> '[1,3,11,110,62,22,4,0,43,21,22,18,6,28,64,9,11,1,0,0,1,40,101,21,20,2,4,2,2,9,18,35,1,1,7,25,108,116,63,2,0,0,11,74,40,101,116,3,33,1,1,11,14,18,116,116,68,12,5,4,2,2,9,102,17,3,10,18,8,15,67,63,15,0,14,116,80,0,2,22,96,37|
-> Parallel Seq Scan on t3 (cost=0.00..77679.00 rows=416667 width=12) |
source /Users/arjunsunilkumar/GolandProjects/mo_dump/sift128_no_index.sql
-- takes about <5secs in the master.
-- experimenting: if with the PK column defined, we have any fast path for table scans.
ALTER TABLE t3 ADD PRIMARY KEY (a);
mysql> create index idx3 using ivfflat on t3(b) lists=500 op_type "vector_l2_ops"; Query OK, 0 rows affected (6 min 8.79 sec)
4. Run the query
```sql
explain analyze SELECT a FROM t3 ORDER BY l2_distance(b,'[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]') ASC LIMIT 100;
Download Archive.zip
Run benchmark code. Replace /Users/arjunsunilkumar/Downloads/benchmark/1million128/sift/
with the path where you extracted the above dataset.
Old QPS | New QPS | |
---|---|---|
Without Index + without PK | 1 | 11.97 |
With Index + without PK | 4 | 12.62 |
Without Index + with PK | NA | 1.9 |
With Index + with PK | NA | 23.39 |
Vector In Index Table + With PK + Only Index Tables | NA | 7.1046 |
Vector In Index Table + With PK + tbl INDEX_JOIN entries | NA | 6.8001 |
Entries
table and only use Index tables for outputmysql> explain analyze
-> SELECT a,b FROM t3 ORDER BY l2_distance(b,'[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]') ASC LIMIT 100;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project |
| Analyze: timeConsumed=0ms waitTime=164ms inputRows=100 outputRows=100 InputSize=54000bytes OutputSize=54000bytes MemorySize=54000bytes |
| -> Sort |
| Analyze: timeConsumed=5ms waitTime=327ms inputRows=0 outputRows=100 InputSize=0bytes OutputSize=54000bytes MemorySize=95344bytes |
| Sort Key: l2_distance(#[0,1], cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32)) ASC |
| Limit: 100 |
| -> Join |
| Analyze: timeConsumed=11ms probe_time=[total=11ms,min=0ms,max=1ms,dop=10] build_time=[0ms] waitTime=1780ms inputRows=1000001 outputRows=4068 InputSize=522mb OutputSize=2mb MemorySize=180859bytes |
| Join Type: INNER |
| Join Cond: (__mo_index_secondary_018e7c4d-f1e3-7f37-8704-2b07ff96ae82.__mo_index_centroid_fk_id = __mo_index_secondary_018e7c4d-f1e3-7a91-9277-0e0558bae263.__mo_index_centroid_id) |
| -> Join |
| Analyze: timeConsumed=103ms probe_time=[total=102ms,min=7ms,max=13ms,dop=10] build_time=[0ms] waitTime=1852ms inputRows=1000001 outputRows=1000000 InputSize=530mb OutputSize=522mb MemorySize=180875bytes |
| Join Type: SINGLE |
| Join Cond: (__mo_index_secondary_018e7c4d-f1e3-7f37-8704-2b07ff96ae82.__mo_index_centroid_fk_version = cast(__mo_index_secondary_018e7c4d-f1e3-7e42-9ed1-904d573a226c.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018e7c4d-f1e3-7f37-8704-2b07ff96ae82 |
| Analyze: timeConsumed=1139ms scan_time=[total=1138ms,min=113ms,max=162ms,dop=8] waitTime=158ms inputRows=1000000 outputRows=1000000 InputSize=530mb OutputSize=530mb MemorySize=69mb |
| -> Table Scan on a.__mo_index_secondary_018e7c4d-f1e3-7e42-9ed1-904d573a226c |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7c4d-f1e3-7e42-9ed1-904d573a226c.__mo_index_key = 'version') |
| -> Sort |
| Analyze: timeConsumed=0ms waitTime=1ms inputRows=0 outputRows=1 InputSize=0bytes OutputSize=8bytes MemorySize=4024bytes |
| Sort Key: l2_distance(__mo_index_secondary_018e7c4d-f1e3-7a91-9277-0e0558bae263.__mo_index_centroid, normalize_l2(cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32))) ASC |
| Limit: CASE WHEN (@probe_limit IS NULL) THEN 1 ELSE cast(@probe_limit AS BIGINT) END |
| -> Join |
| Analyze: timeConsumed=0ms probe_time=[0ms,0ms] build_time=[0ms] waitTime=1ms inputRows=501 outputRows=500 InputSize=276024bytes OutputSize=272000bytes MemorySize=49347bytes |
| Join Type: SINGLE |
| Join Cond: (__mo_index_secondary_018e7c4d-f1e3-7a91-9277-0e0558bae263.__mo_index_centroid_version = cast(__mo_index_secondary_018e7c4d-f1e3-7e42-9ed1-904d573a226c.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018e7c4d-f1e3-7a91-9277-0e0558bae263 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=500 outputRows=500 InputSize=276000bytes OutputSize=276000bytes MemorySize=552000bytes |
| -> Table Scan on a.__mo_index_secondary_018e7c4d-f1e3-7e42-9ed1-904d573a226c |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7c4d-f1e3-7e42-9ed1-904d573a226c.__mo_index_key = 'version') |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
32 rows in set (0.17 sec)
Entries
table and do INDEX_JOIN
on the topTo switch you need update this value to false: https://github.com/arjunsk/matrixone/pull/85#discussion_r1540293402
mysql> explain analyze SELECT a,b FROM t3 ORDER BY l2_distance(b,'[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]') ASC LIMIT 100;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project |
| Analyze: timeConsumed=0ms waitTime=198ms inputRows=100 outputRows=100 InputSize=54000bytes OutputSize=54000bytes MemorySize=54000bytes |
| -> Join |
| Analyze: timeConsumed=0ms waitTime=2701ms inputRows=200 outputRows=100 InputSize=54400bytes OutputSize=54000bytes MemorySize=0bytes |
| Join Type: INDEX |
| Join Cond: (t3.a = __mo_index_secondary_018e7c4d-f1e3-7f37-8704-2b07ff96ae82.__mo_index_pri_col) |
| Runtime Filter Build: #[-1,0] |
| -> Table Scan on a.t3 |
| Analyze: timeConsumed=237ms scan_time=[total=237ms,min=15ms,max=30ms,dop=10] filter_time=[total=0ms,min=0ms,max=0ms,dop=10] waitTime=35ms inputRows=100 outputRows=100 InputSize=54000bytes OutputSize=54000bytes MemorySize=66520bytes |
| Runtime Filter Probe: t3.a |
| -> Sort |
| Analyze: timeConsumed=4ms waitTime=323ms inputRows=0 outputRows=100 InputSize=0bytes OutputSize=400bytes MemorySize=41744bytes |
| Sort Key: l2_distance(#[0,1], cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32)) ASC |
| Limit: 100 |
| -> Join |
| Analyze: timeConsumed=10ms probe_time=[total=10ms,min=0ms,max=1ms,dop=10] build_time=[0ms] waitTime=1761ms inputRows=1000001 outputRows=4068 InputSize=522mb OutputSize=2mb MemorySize=180859bytes |
| Join Type: INNER |
| Join Cond: (__mo_index_secondary_018e7c4d-f1e3-7f37-8704-2b07ff96ae82.__mo_index_centroid_fk_id = __mo_index_secondary_018e7c4d-f1e3-7a91-9277-0e0558bae263.__mo_index_centroid_id) |
| -> Join |
| Analyze: timeConsumed=81ms probe_time=[total=81ms,min=4ms,max=19ms,dop=10] build_time=[0ms] waitTime=1847ms inputRows=1000001 outputRows=1000000 InputSize=530mb OutputSize=522mb MemorySize=180875bytes |
| Join Type: SINGLE |
| Join Cond: (__mo_index_secondary_018e7c4d-f1e3-7f37-8704-2b07ff96ae82.__mo_index_centroid_fk_version = cast(__mo_index_secondary_018e7c4d-f1e3-7e42-9ed1-904d573a226c.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018e7c4d-f1e3-7f37-8704-2b07ff96ae82 |
| Analyze: timeConsumed=1065ms scan_time=[total=1064ms,min=101ms,max=158ms,dop=8] waitTime=102ms inputRows=1000000 outputRows=1000000 InputSize=530mb OutputSize=530mb MemorySize=69mb |
| -> Table Scan on a.__mo_index_secondary_018e7c4d-f1e3-7e42-9ed1-904d573a226c |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7c4d-f1e3-7e42-9ed1-904d573a226c.__mo_index_key = 'version') |
| -> Sort |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=1 InputSize=0bytes OutputSize=8bytes MemorySize=4024bytes |
| Sort Key: l2_distance(__mo_index_secondary_018e7c4d-f1e3-7a91-9277-0e0558bae263.__mo_index_centroid, normalize_l2(cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32))) ASC |
| Limit: CASE WHEN (@probe_limit IS NULL) THEN 1 ELSE cast(@probe_limit AS BIGINT) END |
| -> Join |
| Analyze: timeConsumed=0ms probe_time=[0ms,0ms] build_time=[0ms] waitTime=0ms inputRows=501 outputRows=500 InputSize=276024bytes OutputSize=272000bytes MemorySize=49347bytes |
| Join Type: SINGLE |
| Join Cond: (__mo_index_secondary_018e7c4d-f1e3-7a91-9277-0e0558bae263.__mo_index_centroid_version = cast(__mo_index_secondary_018e7c4d-f1e3-7e42-9ed1-904d573a226c.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018e7c4d-f1e3-7a91-9277-0e0558bae263 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=500 outputRows=500 InputSize=276000bytes OutputSize=276000bytes MemorySize=552000bytes |
| -> Table Scan on a.__mo_index_secondary_018e7c4d-f1e3-7e42-9ed1-904d573a226c |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7c4d-f1e3-7e42-9ed1-904d573a226c.__mo_index_key = 'version') |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
40 rows in set (0.21 sec)
https://github.com/arjunsk/matrixone/pull/85/files
explain analyze
select `__mo_index_pri_col`, `__mo_index_centroid_fk_entry` from `__mo_index_secondary_018e7ca4-1f5b-7881-9aae-f6cbef94d09f`
where `__mo_index_centroid_fk_version`=(select CAST(`__mo_index_val` as BIGINT) from `__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e` where `__mo_index_key` = 'version') and `__mo_index_centroid_fk_id`
in (
select `__mo_index_centroid_id` from `__mo_index_secondary_018e7ca4-1f5b-7720-bed9-8bfaa84588ad`
where `__mo_index_centroid_version`= (select CAST(`__mo_index_val` as BIGINT) from `__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e` where `__mo_index_key` = 'version')
order by l2_distance(`__mo_index_centroid`, normalize_l2('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]')) asc limit 1
)
order by l2_distance(`__mo_index_centroid_fk_entry`, '[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]') asc limit 100;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project |
| Analyze: timeConsumed=0ms waitTime=189ms inputRows=100 outputRows=100 InputSize=54000bytes OutputSize=54000bytes MemorySize=54000bytes |
| -> Sort |
| Analyze: timeConsumed=5ms waitTime=376ms inputRows=0 outputRows=100 InputSize=0bytes OutputSize=54000bytes MemorySize=71152bytes |
| Sort Key: l2_distance(__mo_index_secondary_018e7ca4-1f5b-7881-9aae-f6cbef94d09f.__mo_index_centroid_fk_entry, cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32)) ASC |
| Limit: 100 |
| -> Join |
| Analyze: timeConsumed=10ms probe_time=[total=10ms,min=0ms,max=2ms,dop=10] build_time=[0ms] waitTime=2058ms inputRows=1000001 outputRows=1057 InputSize=522mb OutputSize=570780bytes MemorySize=180859bytes |
| Join Type: SEMI |
| Join Cond: (__mo_index_secondary_018e7ca4-1f5b-7881-9aae-f6cbef94d09f.__mo_index_centroid_fk_id = __mo_index_secondary_018e7ca4-1f5b-7720-bed9-8bfaa84588ad.__mo_index_centroid_id) |
| -> Filter |
| Analyze: timeConsumed=28ms waitTime=0ms inputRows=1000000 outputRows=1000000 InputSize=553mb OutputSize=522mb MemorySize=43mb |
| Filter Cond: (__mo_index_secondary_018e7ca4-1f5b-7881-9aae-f6cbef94d09f.__mo_index_centroid_fk_version = cast(__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_val AS BIGINT)) |
| -> Join |
| Analyze: timeConsumed=282ms probe_time=[total=281ms,min=20ms,max=51ms,dop=10] build_time=[0ms] waitTime=1917ms inputRows=1000001 outputRows=1000000 InputSize=530mb OutputSize=553mb MemorySize=24bytes |
| Join Type: SINGLE |
| -> Table Scan on a.__mo_index_secondary_018e7ca4-1f5b-7881-9aae-f6cbef94d09f |
| Analyze: timeConsumed=1347ms scan_time=[total=1347ms,min=144ms,max=184ms,dop=8] waitTime=170ms inputRows=1000000 outputRows=1000000 InputSize=530mb OutputSize=530mb MemorySize=69mb |
| -> Table Scan on a.__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_key = 'version') |
| Block Filter Cond: (__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_key = 'version') |
| -> Sort |
| Analyze: timeConsumed=0ms waitTime=5ms inputRows=0 outputRows=1 InputSize=0bytes OutputSize=8bytes MemorySize=4024bytes |
| Sort Key: l2_distance(__mo_index_secondary_018e7ca4-1f5b-7720-bed9-8bfaa84588ad.__mo_index_centroid, normalize_l2(cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32))) ASC |
| Limit: 1 |
| -> Filter |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=500 outputRows=500 InputSize=288000bytes OutputSize=272000bytes MemorySize=272500bytes |
| Filter Cond: (__mo_index_secondary_018e7ca4-1f5b-7720-bed9-8bfaa84588ad.__mo_index_centroid_version = cast(__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_val AS BIGINT)) |
| -> Join |
| Analyze: timeConsumed=0ms probe_time=[0ms,0ms] build_time=[0ms] waitTime=6ms inputRows=501 outputRows=500 InputSize=276024bytes OutputSize=288000bytes MemorySize=24bytes |
| Join Type: SINGLE |
| -> Table Scan on a.__mo_index_secondary_018e7ca4-1f5b-7720-bed9-8bfaa84588ad |
| Analyze: timeConsumed=2ms waitTime=0ms inputRows=500 outputRows=500 InputSize=276000bytes OutputSize=276000bytes MemorySize=552000bytes |
| -> Table Scan on a.__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_key = 'version') |
| Block Filter Cond: (__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_key = 'version') |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
38 rows in set (0.19 sec)
mysql> explain analyze
-> SELECT a,b FROM t3 ORDER BY l2_distance(b,'[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]') ASC LIMIT 100;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project |
| Analyze: timeConsumed=0ms waitTime=169ms inputRows=100 outputRows=100 InputSize=54000bytes OutputSize=54000bytes MemorySize=54000bytes |
| -> Sort |
| Analyze: timeConsumed=3ms waitTime=337ms inputRows=0 outputRows=100 InputSize=0bytes OutputSize=54000bytes MemorySize=70800bytes |
| Sort Key: l2_distance(#[0,1], cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32)) ASC |
| Limit: 100 |
| -> Join |
| Analyze: timeConsumed=10ms probe_time=[total=9ms,min=0ms,max=1ms,dop=10] build_time=[0ms] waitTime=1840ms inputRows=1000001 outputRows=1057 InputSize=522mb OutputSize=570780bytes MemorySize=180859bytes |
| Join Type: SEMI |
| Join Cond: (__mo_index_secondary_018e7ca4-1f5b-7881-9aae-f6cbef94d09f.__mo_index_centroid_fk_id = __mo_index_secondary_018e7ca4-1f5b-7720-bed9-8bfaa84588ad.__mo_index_centroid_id) |
| -> Join |
| Analyze: timeConsumed=197ms probe_time=[total=197ms,min=14ms,max=27ms,dop=10] build_time=[0ms] waitTime=1807ms inputRows=1000001 outputRows=1000000 InputSize=530mb OutputSize=522mb MemorySize=180875bytes |
| Join Type: SINGLE |
| Join Cond: (__mo_index_secondary_018e7ca4-1f5b-7881-9aae-f6cbef94d09f.__mo_index_centroid_fk_version = cast(__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018e7ca4-1f5b-7881-9aae-f6cbef94d09f |
| Analyze: timeConsumed=1222ms scan_time=[total=1222ms,min=139ms,max=165ms,dop=8] waitTime=160ms inputRows=1000000 outputRows=1000000 InputSize=530mb OutputSize=530mb MemorySize=69mb |
| -> Table Scan on a.__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_key = 'version') |
| -> Sort |
| Analyze: timeConsumed=0ms waitTime=1ms inputRows=0 outputRows=1 InputSize=0bytes OutputSize=8bytes MemorySize=4024bytes |
| Sort Key: l2_distance(__mo_index_secondary_018e7ca4-1f5b-7720-bed9-8bfaa84588ad.__mo_index_centroid, normalize_l2(cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32))) ASC |
| Limit: CASE WHEN (@probe_limit IS NULL) THEN 1 ELSE cast(@probe_limit AS BIGINT) END |
| -> Join |
| Analyze: timeConsumed=0ms probe_time=[0ms,0ms] build_time=[0ms] waitTime=1ms inputRows=501 outputRows=500 InputSize=276024bytes OutputSize=272000bytes MemorySize=49347bytes |
| Join Type: SINGLE |
| Join Cond: (__mo_index_secondary_018e7ca4-1f5b-7720-bed9-8bfaa84588ad.__mo_index_centroid_version = cast(__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018e7ca4-1f5b-7720-bed9-8bfaa84588ad |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=500 outputRows=500 InputSize=276000bytes OutputSize=276000bytes MemorySize=552000bytes |
| -> Table Scan on a.__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_key = 'version') |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
32 rows in set (0.19 sec)
mysql> explain analyze
-> SELECT a,b FROM t3 ORDER BY l2_distance(b,'[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]') ASC LIMIT 100;
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
Connection id: 3326
Current database: a
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project |
| Analyze: timeConsumed=0ms waitTime=145ms inputRows=100 outputRows=100 InputSize=54000bytes OutputSize=54000bytes MemorySize=54000bytes |
| -> Sort |
| Analyze: timeConsumed=3ms waitTime=289ms inputRows=0 outputRows=100 InputSize=0bytes OutputSize=54000bytes MemorySize=70952bytes |
| Sort Key: l2_distance(#[0,1], cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32)) ASC |
| Limit: 100 |
| -> Join |
| Analyze: timeConsumed=12ms probe_time=[total=11ms,min=0ms,max=3ms,dop=10] build_time=[0ms] waitTime=1574ms inputRows=1000001 outputRows=1057 InputSize=522mb OutputSize=570780bytes MemorySize=180859bytes |
| Join Type: SEMI |
| Join Cond: (__mo_index_secondary_018e7ca4-1f5b-7881-9aae-f6cbef94d09f.__mo_index_centroid_fk_id = __mo_index_secondary_018e7ca4-1f5b-7720-bed9-8bfaa84588ad.__mo_index_centroid_id) |
| -> Join |
| Analyze: timeConsumed=388ms probe_time=[total=388ms,min=27ms,max=48ms,dop=10] build_time=[0ms] waitTime=1323ms inputRows=1000001 outputRows=1000000 InputSize=530mb OutputSize=522mb MemorySize=180875bytes |
| Join Type: SEMI |
| Join Cond: (__mo_index_secondary_018e7ca4-1f5b-7881-9aae-f6cbef94d09f.__mo_index_centroid_fk_version = cast(__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018e7ca4-1f5b-7881-9aae-f6cbef94d09f |
| Analyze: timeConsumed=965ms scan_time=[total=965ms,min=101ms,max=139ms,dop=8] waitTime=111ms inputRows=1000000 outputRows=1000000 InputSize=530mb OutputSize=530mb MemorySize=69mb |
| -> Table Scan on a.__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_key = 'version') |
| -> Sort |
| Analyze: timeConsumed=0ms waitTime=2ms inputRows=0 outputRows=1 InputSize=0bytes OutputSize=8bytes MemorySize=4024bytes |
| Sort Key: l2_distance(__mo_index_secondary_018e7ca4-1f5b-7720-bed9-8bfaa84588ad.__mo_index_centroid, normalize_l2(cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32))) ASC |
| Limit: CASE WHEN (@probe_limit IS NULL) THEN 1 ELSE cast(@probe_limit AS BIGINT) END |
| -> Join |
| Analyze: timeConsumed=0ms probe_time=[0ms,0ms] build_time=[0ms] waitTime=1ms inputRows=501 outputRows=500 InputSize=276024bytes OutputSize=272000bytes MemorySize=49347bytes |
| Join Type: SEMI |
| Join Cond: (__mo_index_secondary_018e7ca4-1f5b-7720-bed9-8bfaa84588ad.__mo_index_centroid_version = cast(__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018e7ca4-1f5b-7720-bed9-8bfaa84588ad |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=500 outputRows=500 InputSize=276000bytes OutputSize=276000bytes MemorySize=552000bytes |
| -> Table Scan on a.__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7ca4-1f5b-7903-bdec-44c2ff16a66e.__mo_index_key = 'version') |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
32 rows in set (0.17 sec)
QPS: 6.78
explain analyze
SELECT a,b FROM t3 ORDER BY l2_distance(b,'[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]') ASC LIMIT 100;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project |
| Analyze: timeConsumed=0ms waitTime=250ms inputRows=100 outputRows=100 InputSize=54000bytes OutputSize=54000bytes MemorySize=54000bytes |
| -> Sort |
| Analyze: timeConsumed=1ms waitTime=499ms inputRows=0 outputRows=100 InputSize=0bytes OutputSize=54000bytes MemorySize=82648bytes |
| Sort Key: l2_distance(#[0,1], cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32)) ASC |
| Limit: 100 |
| -> Join |
| Analyze: timeConsumed=1ms probe_time=[total=1ms,min=0ms,max=1ms,dop=10] build_time=[0ms] waitTime=2744ms inputRows=3282 outputRows=3281 InputSize=1mb OutputSize=1mb MemorySize=180875bytes |
| Join Type: SEMI |
| Join Cond: (__mo_index_secondary_018e7e97-aaa2-7a92-ae7a-f5c186ff627b.__mo_index_centroid_fk_version = cast(__mo_index_secondary_018e7e97-aaa2-7607-8e60-0732829dab99.__mo_index_val AS BIGINT)) |
| -> Join |
| Analyze: timeConsumed=12ms probe_time=[total=12ms,min=0ms,max=2ms,dop=10] build_time=[0ms] waitTime=2981ms inputRows=1000001 outputRows=3281 InputSize=530mb OutputSize=1mb MemorySize=180859bytes |
| Join Type: SEMI |
| Join Cond: (__mo_index_secondary_018e7e97-aaa2-7a92-ae7a-f5c186ff627b.__mo_index_centroid_fk_id = __mo_index_secondary_018e7e97-aaa2-7b63-8330-7d6ca43d0454.__mo_index_centroid_id) |
| -> Table Scan on a.__mo_index_secondary_018e7e97-aaa2-7a92-ae7a-f5c186ff627b |
| Analyze: timeConsumed=1904ms scan_time=[total=1904ms,min=219ms,max=249ms,dop=8] waitTime=238ms inputRows=1000000 outputRows=1000000 InputSize=530mb OutputSize=530mb MemorySize=69mb |
| -> Sort |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=1 InputSize=0bytes OutputSize=8bytes MemorySize=4016bytes |
| Sort Key: l2_distance(__mo_index_secondary_018e7e97-aaa2-7b63-8330-7d6ca43d0454.__mo_index_centroid, normalize_l2(cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32))) ASC |
| Limit: CASE WHEN (@probe_limit IS NULL) THEN 1 ELSE cast(@probe_limit AS BIGINT) END |
| -> Join |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=500 InputSize=24bytes OutputSize=272000bytes MemorySize=32906bytes |
| Join Type: SINGLE |
| Join Cond: (__mo_index_secondary_018e7e97-aaa2-7b63-8330-7d6ca43d0454.__mo_index_centroid_version = cast(__mo_index_secondary_018e7e97-aaa2-7607-8e60-0732829dab99.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018e7e97-aaa2-7b63-8330-7d6ca43d0454 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=500 outputRows=500 InputSize=276000bytes OutputSize=276000bytes MemorySize=552000bytes |
| -> Table Scan on a.__mo_index_secondary_018e7e97-aaa2-7607-8e60-0732829dab99 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7e97-aaa2-7607-8e60-0732829dab99.__mo_index_key = 'version') |
| -> Table Scan on a.__mo_index_secondary_018e7e97-aaa2-7607-8e60-0732829dab99 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e7e97-aaa2-7607-8e60-0732829dab99.__mo_index_key = 'version') |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
32 rows in set (0.26 sec)
mysql> select * from mo_catalog.mo_indexes where name="idx3";
+------+----------+-------------+------+----------+---------+-----------------+-------------------------------------------+------------+--------+---------+-------------+------------------+---------+-----------------------------------------------------------+
| id | table_id | database_id | name | type | algo | algo_table_type | algo_params | is_visible | hidden | comment | column_name | ordinal_position | options | index_table_name |
+------+----------+-------------+------+----------+---------+-----------------+-------------------------------------------+------------+--------+---------+-------------+------------------+---------+-----------------------------------------------------------+
| 63 | 272519 | 272518 | idx3 | MULTIPLE | ivfflat | metadata | {"lists":"500","op_type":"vector_l2_ops"} | 1 | 0 | | b | 1 | NULL | __mo_index_secondary_018e7e97-aaa2-7607-8e60-0732829dab99 |
| 64 | 272519 | 272518 | idx3 | MULTIPLE | ivfflat | centroids | {"lists":"500","op_type":"vector_l2_ops"} | 1 | 0 | | b | 1 | NULL | __mo_index_secondary_018e7e97-aaa2-7b63-8330-7d6ca43d0454 |
| 65 | 272519 | 272518 | idx3 | MULTIPLE | ivfflat | entries | {"lists":"500","op_type":"vector_l2_ops"} | 1 | 0 | | b | 1 | NULL | __mo_index_secondary_018e7e97-aaa2-7a92-ae7a-f5c186ff627b |
+------+----------+-------------+------+----------+---------+-----------------+-------------------------------------------+------------+--------+---------+-------------+------------------+---------+-----------------------------------------------------------+
3 rows in set (0.01 sec)
mysql> desc `__mo_index_secondary_018e7e97-aaa2-7b63-8330-7d6ca43d0454`;
+-----------------------------+-------------+------+------+---------+-------+---------+
| Field | Type | Null | Key | Default | Extra | Comment |
+-----------------------------+-------------+------+------+---------+-------+---------+
| __mo_index_centroid_version | BIGINT(64) | NO | PRI | NULL | | |
| __mo_index_centroid_id | BIGINT(64) | NO | PRI | NULL | | |
| __mo_index_centroid | VECF32(128) | YES | | NULL | | |
+-----------------------------+-------------+------+------+---------+-------+---------+
3 rows in set (0.01 sec)
mysql> desc `__mo_index_secondary_018e7e97-aaa2-7a92-ae7a-f5c186ff627b`;
+--------------------------------+-------------+------+------+---------+-------+---------+
| Field | Type | Null | Key | Default | Extra | Comment |
+--------------------------------+-------------+------+------+---------+-------+---------+
| __mo_index_centroid_fk_version | BIGINT(64) | NO | PRI | NULL | | |
| __mo_index_centroid_fk_id | BIGINT(64) | NO | PRI | NULL | | |
| __mo_index_pri_col | INT(32) | NO | PRI | NULL | | |
| __mo_index_centroid_fk_entry | VECF32(128) | YES | | NULL | | |
+--------------------------------+-------------+------+------+---------+-------+---------+
4 rows in set (0.01 sec)
source /Users/arjunsunilkumar/GolandProjects/mo_dump/sift128_no_index.sql
mysql> create index idx3 using ivfflat on t3(b) lists=500 op_type "vector_l2_ops";
Query OK, 0 rows affected (6 min 8.79 sec)
explain analyze SELECT a FROM t3 ORDER BY l2_distance(b,'[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]') ASC LIMIT 100;
Waiting for this issue: https://github.com/matrixorigin/matrixone/issues/15196
Using INDEX JOIN to join TableScan and SortNode gives the wrong output.
drop table vector_index_01;
create table vector_index_01(a int primary key, b vecf32(128),c int,key c_k(c));
insert into vector_index_01 values(9774 ,"[1, 0, 1, 6, 6, 17, 47, 39, 2, 0, 1, 25, 27, 10, 56, 130, 18, 5, 2, 6, 15, 2, 19, 130, 42, 28, 1, 1, 2, 1, 0, 5, 0, 2, 4, 4, 31, 34, 44, 35, 9, 3, 8, 11, 33, 12, 61, 130, 130, 17, 0, 1, 6, 2, 9, 130, 111, 36, 0, 0, 11, 9, 1, 12, 2, 100, 130, 28, 7, 2, 6, 7, 9, 27, 130, 83, 5, 0, 1, 18, 130, 130, 84, 9, 0, 0, 2, 24, 111, 24, 0, 1, 37, 24, 2, 10, 12, 62, 33, 3, 0, 0, 0, 1, 3, 16, 106, 28, 0, 0, 0, 0, 17, 46, 85, 10, 0, 0, 1, 4, 11, 4, 2, 2, 9, 14, 8, 8]",3),(9775,"[0, 1, 1, 3, 0, 3, 46, 20, 1, 4, 17, 9, 1, 17, 108, 15, 0, 3, 37, 17, 6, 15, 116, 16, 6, 1, 4, 7, 7, 7, 9, 6, 0, 8, 10, 4, 26, 129, 27, 9, 0, 0, 5, 2, 11, 129, 129, 12, 103, 4, 0, 0, 2, 31, 129, 129, 94, 4, 0, 0, 0, 3, 13, 42, 0, 15, 38, 2, 70, 129, 1, 0, 5, 10, 40, 12, 74, 129, 6, 1, 129, 39, 6, 1, 2, 22, 9, 33, 122, 13, 0, 0, 0, 0, 5, 23, 4, 11, 9, 12, 45, 38, 1, 0, 0, 4, 36, 38, 57, 32, 0, 0, 82, 22, 9, 5, 13, 11, 3, 94, 35, 3, 0, 0, 0, 1, 16, 97]",5),(9776,"[10, 3, 8, 5, 48, 26, 5, 16, 17, 0, 0, 2, 132, 53, 1, 16, 112, 6, 0, 0, 7, 2, 1, 48, 48, 15, 18, 31, 3, 0, 0, 9, 6, 10, 19, 27, 50, 46, 17, 9, 18, 1, 4, 48, 132, 23, 3, 5, 132, 9, 4, 3, 11, 0, 2, 46, 84, 12, 10, 10, 1, 0, 12, 76, 26, 22, 16, 26, 35, 15, 3, 16, 15, 1, 51, 132, 125, 8, 1, 2, 132, 51, 67, 91, 8, 0, 0, 30, 126, 39, 32, 38, 4, 0, 1, 12, 24, 2, 2, 2, 4, 7, 2, 19, 93, 19, 70, 92, 2, 3, 1, 21, 36, 58, 132, 94, 0, 0, 0, 0, 21, 25, 57, 48, 1, 0, 0, 1]",3);
insert into vector_index_01 values(9777, " [16, 15, 0, 0, 5, 46, 5, 5, 4, 0, 0, 0, 28, 118, 12, 5, 75, 44, 5, 0, 6, 32, 6, 49, 41, 74, 9, 1, 0, 0, 0, 9, 1, 9, 16, 41, 71, 80, 3, 0, 0, 4, 3, 5, 51, 106, 11, 3, 112, 28, 13, 1, 4, 8, 3, 104, 118, 14, 1, 1, 0, 0, 0, 88, 3, 27, 46, 118, 108, 49, 2, 0, 1, 46, 118, 118, 27, 12, 0, 0, 33, 118, 118, 8, 0, 0, 0, 4, 118, 95, 40, 0, 0, 0, 1, 11, 27, 38, 12, 12, 18, 29, 3, 2, 13, 30, 94, 78, 30, 19, 9, 3, 31, 45, 70, 42, 15, 1, 3, 12, 14, 22, 16, 2, 3, 17, 24, 13]",4),(9778,"[41, 0, 0, 7, 1, 1, 20, 67, 9, 0, 0, 0, 0, 31, 120, 61, 25, 0, 0, 0, 0, 10, 120, 90, 32, 0, 0, 1, 13, 11, 22, 50, 4, 0, 2, 93, 40, 15, 37, 18, 12, 2, 2, 19, 8, 44, 120, 25, 120, 5, 0, 0, 0, 2, 48, 97, 102, 14, 3, 3, 11, 9, 34, 41, 0, 0, 4, 120, 56, 3, 4, 5, 6, 15, 37, 116, 28, 0, 0, 3, 120, 120, 24, 6, 2, 0, 1, 28, 53, 90, 51, 11, 11, 2, 12, 14, 8, 6, 4, 30, 9, 1, 4, 22, 25, 79, 120, 66, 5, 0, 0, 6, 42, 120, 91, 43, 15, 2, 4, 39, 12, 9, 9, 12, 15, 5, 24, 36]",4);
select a from vector_index_01 order by L2_DISTANCE(b, "[16, 15, 0, 0, 5, 46, 5, 5, 4, 0, 0, 0, 28, 118, 12, 5, 75, 44, 5, 0, 6, 32, 6, 49, 41, 74, 9, 1, 0, 0, 0, 9, 1, 9, 16, 41, 71, 80, 3, 0, 0, 4, 3, 5, 51, 106, 11, 3, 112, 28, 13, 1, 4, 8, 3, 104, 118, 14, 1, 1, 0, 0, 0, 88, 3, 27, 46, 118, 108, 49, 2, 0, 1, 46, 118, 118, 27, 12, 0, 0, 33, 118, 118, 8, 0, 0, 0, 4, 118, 95, 40, 0, 0, 0, 1, 11, 27, 38, 12, 12, 18, 29, 3, 2, 13, 30, 94, 78, 30, 19, 9, 3, 31, 45, 70, 42, 15, 1, 3, 12, 14, 22, 16, 2, 3, 17, 24, 13]") ASC LIMIT 2;
+------+
| a |
+------+
| 9777 |
| 9776 |
+------+
2 rows in set (0.00 sec)
+------+
| a |
+------+
| 9774 |
| 9775 |
+------+
2 rows in set (0.01 sec)
mysql>
mysql> explain analyze
-> SELECT a,b FROM t3 ORDER BY l2_distance(b,'[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]') ASC LIMIT 100;
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
Connection id: 4052
Current database: a
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project |
| Analyze: timeConsumed=0ms waitTime=207ms inputRows=100 outputRows=100 InputSize=253168bytes OutputSize=253168bytes MemorySize=253168bytes |
| -> Join |
| Analyze: timeConsumed=0ms waitTime=2384ms inputRows=11180 outputRows=100 InputSize=2mb OutputSize=253168bytes MemorySize=0bytes |
| Join Type: INDEX |
| Join Cond: (t3.a = __mo_index_secondary_018e9d5b-bd98-7e91-86ac-c2ac887c8c99.__mo_index_pri_col) |
| Runtime Filter Build: #[-1,0] |
| Limit: 100 |
| -> Table Scan on a.t3 |
| Analyze: timeConsumed=1465ms scan_time=[total=1463ms,min=116ms,max=198ms,dop=9] filter_time=[total=1ms,min=0ms,max=0ms,dop=9] waitTime=198ms inputRows=5590 outputRows=5590 InputSize=2mb OutputSize=2mb MemorySize=3mb |
| Runtime Filter Probe: t3.a |
| -> Sort |
| Analyze: timeConsumed=2ms sort_time=[total=2ms,min=0ms,max=2ms,dop=10] mergesort_time=[0ms] waitTime=7ms inputRows=0 outputRows=5590 InputSize=0bytes OutputSize=22360bytes MemorySize=22360bytes |
| Sort Key: l2_distance(__mo_index_secondary_018e9d5b-bd98-7e91-86ac-c2ac887c8c99.__mo_index_centroid_fk_entry, cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32)) ASC |
| -> Join |
| Analyze: timeConsumed=3ms probe_time=[total=3ms,min=0ms,max=3ms,dop=10] build_time=[0ms] waitTime=30ms inputRows=5591 outputRows=5590 InputSize=4mb OutputSize=2mb MemorySize=180859bytes |
| Join Type: SEMI |
| Join Cond: (__mo_index_secondary_018e9d5b-bd98-7e91-86ac-c2ac887c8c99.__mo_index_centroid_fk_id = __mo_index_secondary_018e9d5b-bd98-7de9-a664-f6fe37bb1de1.__mo_index_centroid_id) |
| Runtime Filter Build: #[-1,0] |
| -> Table Scan on a.__mo_index_secondary_018e9d5b-bd98-7e91-86ac-c2ac887c8c99 |
| Analyze: timeConsumed=1ms waitTime=0ms inputRows=8192 outputRows=5590 InputSize=4mb OutputSize=4mb MemorySize=8mb |
| Runtime Filter Probe: __mo_index_secondary_018e9d5b-bd98-7e91-86ac-c2ac887c8c99.__mo_index_centroid_fk_id |
| -> Sort |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=1 InputSize=0bytes OutputSize=8bytes MemorySize=4024bytes |
| Sort Key: l2_distance(__mo_index_secondary_018e9d5b-bd98-7de9-a664-f6fe37bb1de1.__mo_index_centroid, normalize_l2(cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32))) ASC |
| Limit: CASE WHEN (@probe_limit IS NULL) THEN 1 ELSE cast(@probe_limit AS BIGINT) END |
| -> Join |
| Analyze: timeConsumed=0ms probe_time=[0ms,0ms] build_time=[0ms] waitTime=0ms inputRows=501 outputRows=500 InputSize=276024bytes OutputSize=272000bytes MemorySize=49347bytes |
| Join Type: INNER |
| Join Cond: (__mo_index_secondary_018e9d5b-bd98-7de9-a664-f6fe37bb1de1.__mo_index_centroid_version = cast(__mo_index_secondary_018e9d5b-bd98-7a25-bca2-ae6966dca075.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018e9d5b-bd98-7de9-a664-f6fe37bb1de1 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=500 outputRows=500 InputSize=276000bytes OutputSize=276000bytes MemorySize=552000bytes |
| -> Table Scan on a.__mo_index_secondary_018e9d5b-bd98-7a25-bca2-ae6966dca075 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e9d5b-bd98-7a25-bca2-ae6966dca075.__mo_index_key = 'version') |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
35 rows in set (0.22 sec)
mysql>
mysql> explain analyze
-> SELECT a,b FROM t3 ORDER BY l2_distance(b,'[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]') ASC LIMIT 100;
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
Connection id: 4208
Current database: a
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project |
| Analyze: timeConsumed=0ms waitTime=6ms inputRows=100 outputRows=100 InputSize=54000bytes OutputSize=54000bytes MemorySize=54000bytes |
| -> Sort |
| Analyze: timeConsumed=1ms waitTime=12ms inputRows=0 outputRows=100 InputSize=0bytes OutputSize=54000bytes MemorySize=100320bytes |
| Sort Key: l2_distance(__mo_index_secondary_018e9d5b-bd98-7e91-86ac-c2ac887c8c99.__mo_index_centroid_fk_entry, cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32)) ASC |
| Limit: 100 |
| -> Join |
| Analyze: timeConsumed=3ms probe_time=[total=3ms,min=0ms,max=3ms,dop=10] build_time=[0ms] waitTime=20ms inputRows=5591 outputRows=5590 InputSize=4mb OutputSize=2mb MemorySize=180859bytes |
| Join Type: SEMI |
| Join Cond: (__mo_index_secondary_018e9d5b-bd98-7e91-86ac-c2ac887c8c99.__mo_index_centroid_fk_id = __mo_index_secondary_018e9d5b-bd98-7de9-a664-f6fe37bb1de1.__mo_index_centroid_id) |
| Runtime Filter Build: #[-1,0] |
| -> Table Scan on a.__mo_index_secondary_018e9d5b-bd98-7e91-86ac-c2ac887c8c99 |
| Analyze: timeConsumed=1ms waitTime=0ms inputRows=8192 outputRows=5590 InputSize=4mb OutputSize=4mb MemorySize=8mb |
| Runtime Filter Probe: __mo_index_secondary_018e9d5b-bd98-7e91-86ac-c2ac887c8c99.__mo_index_centroid_fk_id |
| -> Sort |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=1 InputSize=0bytes OutputSize=8bytes MemorySize=4024bytes |
| Sort Key: l2_distance(__mo_index_secondary_018e9d5b-bd98-7de9-a664-f6fe37bb1de1.__mo_index_centroid, normalize_l2(cast('[1.0,3.0,11.0,110.0,62.0,22.0,4.0,0.0,43.0,21.0,22.0,18.0,6.0,28.0,64.0,9.0,11.0,1.0,0.0,0.0,1.0,40.0,101.0,21.0,20.0,2.0,4.0,2.0,2.0,9.0,18.0,35.0,1.0,1.0,7.0,25.0,108.0,116.0,63.0,2.0,0.0,0.0,11.0,74.0,40.0,101.0,116.0,3.0,33.0,1.0,1.0,11.0,14.0,18.0,116.0,116.0,68.0,12.0,5.0,4.0,2.0,2.0,9.0,102.0,17.0,3.0,10.0,18.0,8.0,15.0,67.0,63.0,15.0,0.0,14.0,116.0,80.0,0.0,2.0,22.0,96.0,37.0,28.0,88.0,43.0,1.0,4.0,18.0,116.0,51.0,5.0,11.0,32.0,14.0,8.0,23.0,44.0,17.0,12.0,9.0,0.0,0.0,19.0,37.0,85.0,18.0,16.0,104.0,22.0,6.0,2.0,26.0,12.0,58.0,67.0,82.0,25.0,12.0,2.0,2.0,25.0,18.0,8.0,2.0,19.0,42.0,48.0,11.0]' AS VECF32))) ASC |
| Limit: CASE WHEN (@probe_limit IS NULL) THEN 1 ELSE cast(@probe_limit AS BIGINT) END |
| -> Join |
| Analyze: timeConsumed=0ms probe_time=[0ms,0ms] build_time=[0ms] waitTime=0ms inputRows=501 outputRows=500 InputSize=276024bytes OutputSize=272000bytes MemorySize=49347bytes |
| Join Type: INNER |
| Join Cond: (__mo_index_secondary_018e9d5b-bd98-7de9-a664-f6fe37bb1de1.__mo_index_centroid_version = cast(__mo_index_secondary_018e9d5b-bd98-7a25-bca2-ae6966dca075.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018e9d5b-bd98-7de9-a664-f6fe37bb1de1 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=500 outputRows=500 InputSize=276000bytes OutputSize=276000bytes MemorySize=552000bytes |
| -> Table Scan on a.__mo_index_secondary_018e9d5b-bd98-7a25-bca2-ae6966dca075 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018e9d5b-bd98-7a25-bca2-ae6966dca075.__mo_index_key = 'version') |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
27 rows in set (0.03 sec)
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project |
| Analyze: timeConsumed=0ms waitTime=1ms inputRows=3 outputRows=3 InputSize=156bytes OutputSize=156bytes MemorySize=156bytes |
| -> Join |
| Analyze: timeConsumed=0ms waitTime=15ms inputRows=6 outputRows=3 InputSize=168bytes OutputSize=156bytes MemorySize=0bytes |
| Join Type: INDEX |
| Join Cond: (vector_index_04.a = __mo_index_secondary_018ea237-449c-7053-a0d4-5be653091944.__mo_index_pri_col) |
| Runtime Filter Build: #[-1,0] |
| Limit: 3 |
| -> Table Scan on a.vector_index_04 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=3 outputRows=3 InputSize=156bytes OutputSize=156bytes MemorySize=315bytes |
| Runtime Filter Probe: vector_index_04.a |
| -> Sort |
| Analyze: timeConsumed=0ms waitTime=1ms inputRows=0 outputRows=3 InputSize=0bytes OutputSize=12bytes MemorySize=132bytes |
| Sort Key: l2_distance(__mo_index_secondary_018ea237-449c-7053-a0d4-5be653091944.__mo_index_centroid_fk_entry, cast('[9.6,57.22,19.2,78.02]' AS VECF32)) ASC |
| Limit: 3 |
| -> Join |
| Analyze: timeConsumed=0ms probe_time=[0ms,0ms] build_time=[0ms] waitTime=3ms inputRows=10 outputRows=9 InputSize=412bytes OutputSize=252bytes MemorySize=16bytes |
| Join Type: SEMI |
| Join Cond: ((__mo_index_secondary_018ea237-449c-7053-a0d4-5be653091944.__mo_index_centroid_fk_id = __mo_index_secondary_018ea237-449c-76d0-9fc3-dfeb03979e0a.__mo_index_centroid_id) and (__mo_index_secondary_018ea237-449c-7053-a0d4-5be653091944.__mo_index_centroid_fk_version = __mo_index_secondary_018ea237-449c-76d0-9fc3-dfeb03979e0a.__mo_index_centroid_version)) |
| -> Table Scan on a.__mo_index_secondary_018ea237-449c-7053-a0d4-5be653091944 |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=9 outputRows=9 InputSize=396bytes OutputSize=396bytes MemorySize=792bytes |
| -> Sort |
| Analyze: timeConsumed=0ms waitTime=1ms inputRows=0 outputRows=1 InputSize=0bytes OutputSize=16bytes MemorySize=40bytes |
| Sort Key: l2_distance(__mo_index_secondary_018ea237-449c-76d0-9fc3-dfeb03979e0a.__mo_index_centroid, normalize_l2(cast('[9.6,57.22,19.2,78.02]' AS VECF32))) ASC |
| Limit: CASE WHEN (@probe_limit IS NULL) THEN 1 ELSE cast(@probe_limit AS BIGINT) END |
| -> Join |
| Analyze: timeConsumed=0ms probe_time=[0ms,0ms] build_time=[0ms] waitTime=1ms inputRows=2 outputRows=1 InputSize=64bytes OutputSize=40bytes MemorySize=49347bytes |
| Join Type: INNER |
| Join Cond: (__mo_index_secondary_018ea237-449c-76d0-9fc3-dfeb03979e0a.__mo_index_centroid_version = cast(__mo_index_secondary_018ea237-449c-70ac-aaef-0750c2f6af2d.__mo_index_val AS BIGINT)) |
| -> Table Scan on a.__mo_index_secondary_018ea237-449c-76d0-9fc3-dfeb03979e0a |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=40bytes OutputSize=40bytes MemorySize=80bytes |
| -> Table Scan on a.__mo_index_secondary_018ea237-449c-70ac-aaef-0750c2f6af2d |
| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=48bytes OutputSize=24bytes MemorySize=73bytes |
| Filter Cond: (__mo_index_secondary_018ea237-449c-70ac-aaef-0750c2f6af2d.__mo_index_key = 'version') |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
34 rows in set (0.03 sec)
Expected
+------+
| a |
+------+
| 9 |
| 8 |
| 5 |
+------+
Actual (only for INDEX JOIN)
+------+
| a |
+------+
| 5 |
| 8 |
| 9 |
+------+
1.a Only l2_distance
Takes: 3mins 5 secs
1.b l2_distance + normalize_l2
Time: 3mins 13secs
2.a Only serial_full and serial_extract
Time: 1min 45 secs
3.a l2_distance + normalize_l2 + serial_full
Time : 4mins 2secs
3.b l2_distance + normalize_l2 + serial_full + serial_extract
Time: 4mins 4 secs
Parent Issue
https://github.com/matrixorigin/matrixone/issues/10634
Detail of Subtask
Describe implementation you've considered
No response
Additional information
No response