Skip to content
This repository was archived by the owner on Mar 31, 2023. It is now read-only.

[DB] Support SQL Field Query in Alcor #703

Merged
merged 61 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
9645772
Documentation update
pkommoju May 12, 2021
183c36a
Apply changes suggested in review
pkommoju May 22, 2021
4896515
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju May 26, 2021
f170e1e
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju May 28, 2021
bcbf7b1
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju May 29, 2021
efc5b6e
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Jun 1, 2021
c785697
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Jun 8, 2021
d213c03
Merge branch 'master' of https://github.com/pkommoju/alcor
Jun 8, 2021
0f56454
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Jun 8, 2021
4a2a382
Merge branch 'master' of https://github.com/pkommoju/alcor
pkommoju Jun 9, 2021
7f93fe3
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Jun 10, 2021
8d6dd0e
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Jun 15, 2021
b19d428
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
kevin-zhonghao Jun 16, 2021
539d0c0
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Jun 22, 2021
6a9a1c6
Merge branch 'master' of https://github.com/pkommoju/alcor
pkommoju Jun 22, 2021
19430b2
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Jul 1, 2021
1d7ef7e
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Jul 2, 2021
cd1fec6
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Jul 6, 2021
e57abe4
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Jul 20, 2021
1b63054
Add missing file
pkommoju Jul 21, 2021
fe81008
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Jul 21, 2021
118dd53
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Jul 23, 2021
7d9a2e5
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Aug 2, 2021
3884a44
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Aug 4, 2021
0b5cd11
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Aug 6, 2021
3f094be
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Aug 23, 2021
bb777ec
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Sep 10, 2021
c0e8c2d
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Sep 24, 2021
206abc7
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Oct 8, 2021
93e468c
SQLFeildQuery changes (work in progress)
pkommoju Oct 22, 2021
fab8a00
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Oct 22, 2021
0b1395f
Create one index works
pkommoju Oct 28, 2021
80214bd
SQL can select but the value of key column is the literal string
pkommoju Oct 28, 2021
3bb815b
SQL Query works now
pkommoju Oct 28, 2021
05cc857
SQL Query works (one key column, one value column only)
pkommoju Oct 29, 2021
69268a3
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Oct 29, 2021
37044ba
Merge branch 'master' into sqlfieldquery
pkommoju Oct 29, 2021
a40db7e
Fix SQL result from wrong column problem
pkommoju Nov 5, 2021
335b9b8
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Nov 5, 2021
aa78b07
Merge branch 'master' into sqlfieldquery
pkommoju Nov 5, 2021
b68b042
fix filterkey matching bug
pkommoju Nov 8, 2021
8703ec3
Instrument Port, Subnet, Neighbor caches with SQL Fields
pkommoju Nov 8, 2021
f4e8eef
Handle only one of REST, gRPC chnnels being open in NM (TEMP)
pkommoju Nov 8, 2021
dfa0c32
Handle name normalization of dynamic caches
pkommoju Nov 9, 2021
f89e243
Fix filterParams being empty and fallback to scanquery
pkommoju Nov 9, 2021
d1d5744
Handle failed ping test gracefully
pkommoju Nov 9, 2021
33c7972
Fix name normalization
pkommoju Nov 12, 2021
74023d0
fix sql tables not apprearing problem
pkommoju Nov 16, 2021
557a35f
Make SQL Query benchmark a service to avoid insert and query operatin…
pkommoju Nov 17, 2021
67fe492
Query _VAL field instead of specific filed, this works if run with mv…
pkommoju Nov 17, 2021
181f898
Add Scan query benchmark
pkommoju Nov 17, 2021
78ad650
Ignite SqlFieldsQuery changes
pkommoju Nov 19, 2021
6a95d98
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Nov 29, 2021
a8fce0e
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
pkommoju Nov 29, 2021
272874b
Fix merge conflict
pkommoju Nov 29, 2021
5a1ea86
* Address code review comments.
pkommoju Nov 30, 2021
af58b49
Add SQL and Scan query performance comparison report and related arti…
pkommoju Nov 30, 2021
02f04a5
Address more code review comments
pkommoju Nov 30, 2021
913cf6c
Add insert times, remove sqlColumns and rename sqlquery and scan quer…
pkommoju Dec 1, 2021
eb19113
Fix compile error and IntelliJ issues
pkommoju Dec 2, 2021
3cf7110
Set logging level to default
pkommoju Dec 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
OPERATION TYPE MIN MAX AVG MEDIAN MODE P99
SQL_QUERY_EXEC 1.0000 16.0000 1.8739 1.0000 1.0000 1.0000
SCAN_QUERY_EXEC 530182.0000 785735.0000 561550.7678 552705.0000 543704.0000 531308.3565
SQL_CURSOR_FETCH 0.0000 1.0000 0.6717 1.0000 1.0000 0.0000
SCAN_CURSOR_FETCH 0.0000 8.0000 0.1411 0.0000 0.0000 0.0000
SQL_INSERT 0.0000 929676278.00 929.676278 0.0 0.0 0.0
SCAN_INSERT 0.0000 812451365.00 812.451365 0.0 0.0 0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
= SQL Fields Query and Scan Query Performance Comparision
Prasad Kommoju <[email protected]>
2021-11-30
:toc: right
:imagesdir: ../../images


== Introduction
In Alcor there are some cases where queries are made on the cases using a field other than the key. Since Ignite is the KV database, these types of queries will require full scan (linear search) of the cache in question and this introduces big latencies as the number of entries in the cache grows.

Ignite supports secondary keys, called QuerySqlFields which will use a tradional B+Tree indexes which can answer point lookup and also range, minumum, maximum, greater than, and less than queries mush faster.

This report is about comparing the performance of the queries on non-key fields using Ignite's SCAN query and through SQL queries.

== Test setup
Operations are on NodeInfo object. Benchmark tool, DPM, NCM and NMM run on the same physical machine in the lab. Ignite is run on two different physical machines in the lab (partitioned).
Number of entries in both SQL and Scan are 1M, 1000 entries are queried on.

The first query always takes way too much time compared to the subsequent
ones and hence ignored when computing the statistics.

All times are in micro seconds. Time axis (y) in the histogram is in logscale.

SQL_QUERY_EXEC time represents time required to execute the SQLFieldsQuery
(cache.query() API).

SQL_CURSOR_FETCH time represents time required to extract the result from
result set (cursor, cursor.get() API).

SCAN_QUERY_EXEC time represents time required to execute (QueryCursor
instantiation, cache.withKeepBinary().query(...)

SCAN_CURSOR_FETCH time represents time required to extract the result from
result set (cursor, cursor.getAll() API).

For Insert operation, MAX represents total time to insert 1M entires into the cache and AVG represents the average time to insert one single entry. All other statistcs for Insert are not relevant and are shown as zero.

== Results
|===
|OPERATION TYPE| MIN| MAX| AVG| MEDIAN| MODE| P99
|SQL_QUERY_EXEC| 1.0000| 16.0000| 1.8739| 1.0000| 1.0000| 1.0000
|SCAN_QUERY_EXEC| 530182.0000| 785735.0000| 561550.7678| 552705.0000| 543704.0000| 531308.3565
|SQL_CURSOR_FETCH| 0.0000| 1.0000| 0.6717| 1.0000| 1.0000| 0.0000
|SCAN_CURSOR_FETCH| 0.0000 | 8.0000 | 0.1411| 0.0000| 0.0000| 0.0000
|SQL_INSERT| 0.0000 | 929676278.00| 929.6762| 0.0| 0.0| 0.0
|SCAN_INSERT| 0.0000| 812451365.00| 812.4514| 0.0| 0.0| 0.0
|===

== Plot of the results
image::sql_and_scan_query_perf_comp.png[]

6 changes: 6 additions & 0 deletions lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ Copyright(c) 2020 Futurewei Cloud
<version>2.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>29.0-jre</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@ public IgniteClientCacheFactory(IgniteClient igniteClient, int interval, int exp

@Override
public <K, V> ICache<K, V> getCache(Class<V> v) {
return new IgniteClientDbCache<>(igniteClient, v.getName());
return new IgniteClientDbCache<K, V>(igniteClient, v, v.getName());
}

@Override
public <K, V> ICache<K, V> getCache(Class<V> v, String cacheName) {
return new IgniteClientDbCache<>(igniteClient, cacheName);
return new IgniteClientDbCache<K, V>(igniteClient, v, cacheName);
}

@Override
public <K, V> ICache<K, V> getCache(Class<V> v, CacheConfiguration cacheConfig) {
return new IgniteClientDbCache<>(igniteClient, cacheConfig);
return new IgniteClientDbCache<>(igniteClient, v, cacheConfig);
}

@Override
public <K, V> ICache<K, V> getExpireCache(Class<V> v, long timeout, TimeUnit timeUnit) {
ExpiryPolicy ep = CreatedExpiryPolicy.factoryOf(new Duration(timeUnit, timeout)).create();
return new IgniteClientDbCache<>(igniteClient, v.getName(), ep);
return new IgniteClientDbCache<>(igniteClient, v, v.getName(), ep);
}

@Override
Expand All @@ -75,4 +75,4 @@ public <V> IDistributedLock getDistributedLock(Class<V> t) {
public Transaction getTransaction() {
return new IgniteClientTransaction(igniteClient);
}
}
}
Loading