Repository: ignite Updated Branches: refs/heads/master 175c1d815 -> 383d8b2ac
IGNITE-10329: Yardstick: a set of SQL benchmarks against MySQL and PG. This closes #5479. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/383d8b2a Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/383d8b2a Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/383d8b2a Branch: refs/heads/master Commit: 383d8b2ac3147c613f8771957e2ce2d660b29490 Parents: 175c1d8 Author: Pavel Kuznetsov <palmi...@gmail.com> Authored: Tue Dec 25 14:33:49 2018 +0300 Committer: devozerov <voze...@gridgain.com> Committed: Tue Dec 25 14:33:49 2018 +0300 ---------------------------------------------------------------------- .../config/vendors/ignite-config-inmemory.xml | 75 ++++ .../vendors/ignite-config-persistence.xml | 75 ++++ .../ignite-jdbc-thin-select-all.properties | 105 ++++++ .../vendors/ignite-jdbc-thin-select.properties | 109 ++++++ .../vendors/mysql-jdbc-select-all.properties | 91 +++++ .../config/vendors/mysql-jdbc-select.properties | 86 +++++ .../vendors/postgre-jdbc-select-all.properties | 90 +++++ .../vendors/postgre-jdbc-select.properties | 86 +++++ .../yardstick/jdbc/AbstractJdbcBenchmark.java | 9 +- .../jdbc/vendors/BaseSelectRangeBenchmark.java | 342 +++++++++++++++++++ .../yardstick/jdbc/vendors/QueryFactory.java | 127 +++++++ .../jdbc/vendors/ScanAllBenchmark.java | 39 +++ .../jdbc/vendors/ScanAllWithJoinBenchmark.java | 39 +++ .../jdbc/vendors/SelectByPkBenchmark.java | 39 +++ .../vendors/SelectByPkWithJoinBenchmark.java | 39 +++ .../jdbc/vendors/SelectBySalaryBenchmark.java | 36 ++ .../SelectBySalaryWithJoinBenchmark.java | 36 ++ parent/pom.xml | 4 +- 18 files changed, 1424 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/config/vendors/ignite-config-inmemory.xml ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/vendors/ignite-config-inmemory.xml b/modules/yardstick/config/vendors/ignite-config-inmemory.xml new file mode 100644 index 0000000..ddcf95d --- /dev/null +++ b/modules/yardstick/config/vendors/ignite-config-inmemory.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache License, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> + <!-- + Alter configuration below as needed. + --> + <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> + <property name="discoverySpi"> + <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> + <property name="ipFinder"> + <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> + <property name="addresses"> + <list> + <value>127.0.0.1:47500..47520</value> + </list> + </property> + </bean> + </property> + </bean> + </property> + + <!-- Redefining maximum memory size for the cluster node usage. --> + <property name="dataStorageConfiguration"> + <bean class="org.apache.ignite.configuration.DataStorageConfiguration"> + <!-- Redefining the default region's settings --> + <property name="defaultDataRegionConfiguration"> + <bean class="org.apache.ignite.configuration.DataRegionConfiguration"> + <property name="name" value="Default_Region"/> + <!-- Setting the size of the default region to 4GB. --> + <property name="maxSize" value="#{10L * 1024 * 1024 * 1024}"/> + + <!--property name="persistenceEnabled" value="true"/--> + + </bean> + </property> + </bean> + </property> + + <property name="cacheConfiguration"> + <list> + <bean class="org.apache.ignite.configuration.CacheConfiguration"> + <property name="name" value="fakeCache"/> + + <!-- This is a fake cache. Workaround to be able to run IgniteNode in client mode.--> + <property name="cacheMode" value="PARTITIONED"/> + + <property name="atomicityMode" value="ATOMIC"/> + </bean> + </list> + </property> + </bean> + + +</beans> http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/config/vendors/ignite-config-persistence.xml ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/vendors/ignite-config-persistence.xml b/modules/yardstick/config/vendors/ignite-config-persistence.xml new file mode 100644 index 0000000..3bf691c --- /dev/null +++ b/modules/yardstick/config/vendors/ignite-config-persistence.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache License, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> + <!-- + Alter configuration below as needed. + --> + <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> + <property name="discoverySpi"> + <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> + <property name="ipFinder"> + <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> + <property name="addresses"> + <list> + <value>127.0.0.1:47500..47520</value> + </list> + </property> + </bean> + </property> + </bean> + </property> + + <!-- Redefining maximum memory size for the cluster node usage. --> + <property name="dataStorageConfiguration"> + <bean class="org.apache.ignite.configuration.DataStorageConfiguration"> + <!-- Redefining the default region's settings --> + <property name="defaultDataRegionConfiguration"> + <bean class="org.apache.ignite.configuration.DataRegionConfiguration"> + <property name="name" value="Default_Region"/> + <!-- Setting the size of the default region to 4GB. --> + <property name="maxSize" value="#{10L * 1024 * 1024 * 1024}"/> + + <property name="persistenceEnabled" value="true"/> + + </bean> + </property> + </bean> + </property> + + <property name="cacheConfiguration"> + <list> + <bean class="org.apache.ignite.configuration.CacheConfiguration"> + <property name="name" value="fakeCache"/> + + <!-- This is a fake cache. Workaround to be able to run IgniteNode in client mode.--> + <property name="cacheMode" value="PARTITIONED"/> + + <property name="atomicityMode" value="ATOMIC"/> + </bean> + </list> + </property> + </bean> + + +</beans> http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/config/vendors/ignite-jdbc-thin-select-all.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/vendors/ignite-jdbc-thin-select-all.properties b/modules/yardstick/config/vendors/ignite-jdbc-thin-select-all.properties new file mode 100644 index 0000000..071c650 --- /dev/null +++ b/modules/yardstick/config/vendors/ignite-jdbc-thin-select-all.properties @@ -0,0 +1,105 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Thin JDBC driver benchmarks for select and select with join queries. +# Queries in these benchmarks have no WHERE clause. +# + +now0=`date +'%H%M%S'` + +# JVM options. +JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false" + +# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. +JVM_OPTS=${JVM_OPTS}" \ +-Xms8g \ +-Xmx8g \ +-Xloggc:./gc${now0}.log \ +-XX:+PrintGCDetails \ +-verbose:gc \ +-XX:+UseParNewGC \ +-XX:+UseConcMarkSweepGC \ +-XX:+PrintGCDateStamps \ +" + +#Ignite version +ver="RELEASE-" + +# List of default probes. +# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe + +# Since time of each query is big, lets build probe point each 10 seconds. +BENCHMARK_BUILD_PROBE_POINT_INTERVAL=10000 + +# Packages where the specified benchmark is searched by reflection mechanism. +BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick + +# Flag which indicates to restart the servers before every benchmark execution. +RESTART_SERVERS=true + +# Probe point writer class name. +# BENCHMARK_WRITER= + +# This benchmark is designed to use only one node. +SERVER_HOSTS=localhost +DRIVER_HOSTS=localhost + +# Remote username. +# REMOTE_USER= + +# Number of nodes, used to wait for the specified number of nodes to start. +nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} | tr ',' '\n' | wc -l`)) + +# Warmup. +w=60 + +# Duration. +d=300 + +# Threads count. +t=1 + +inmemCfg="${SCRIPT_DIR}/../config/vendors/ignite-config-inmemory.xml" + +persistCfg="${SCRIPT_DIR}/../config/vendors/ignite-config-persistence.xml" + +thinUrl="jdbc:ignite:thin://localhost/" +v2Url="jdbc:ignite:cfg://cache=fakeCache@config/ignite-jdbc-config.xml" + +commonParams="\ + -nn ${nodesNum} \ + -w ${w} -d ${d} \ + -cl --clientNodesAfterId -1 \ + -t ${t} \ + -sn IgniteNode \ + --sqlRange 1000000 \ + --range 1000000" +# Run configuration which contains all benchmarks. +# Note that each benchmark is set to run for 300 seconds (5 min) with warm-up set to 60 seconds (1 minute). +CONFIGS="\ + ${commonParams} -cfg ${inmemCfg} -jdbc ${thinUrl} -dn ScanAllBenchmark -ds ${ver}select-all-jdbc-thin-inmemory, \ + ${commonParams} -cfg ${inmemCfg} -jdbc ${v2Url} -dn ScanAllBenchmark -ds ${ver}select-all-jdbc-v2-inmemory, \ + ${commonParams} -cfg ${persistCfg} -jdbc ${thinUrl} -dn ScanAllBenchmark -ds ${ver}select-all-jdbc-thin-persistence, \ + ${commonParams} -cfg ${persistCfg} -jdbc ${v2Url} -dn ScanAllBenchmark -ds ${ver}select-all-jdbc-v2-persistence, \ + \ + ${commonParams} -cfg ${inmemCfg} -jdbc ${thinUrl} -dn ScanAllWithJoinBenchmark -ds ${ver}select-all-join-jdbc-thin-inmemory, \ + ${commonParams} -cfg ${inmemCfg} -jdbc ${v2Url} -dn ScanAllWithJoinBenchmark -ds ${ver}select-all-join-jdbc-v2-inmemory, \ + ${commonParams} -cfg ${persistCfg} -jdbc ${thinUrl} -dn ScanAllWithJoinBenchmark -ds ${ver}select-all-join-jdbc-thin-persistence, \ + ${commonParams} -cfg ${persistCfg} -jdbc ${v2Url} -dn ScanAllWithJoinBenchmark -ds ${ver}select-all-join-jdbc-v2-persistence \ +" http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/config/vendors/ignite-jdbc-thin-select.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/vendors/ignite-jdbc-thin-select.properties b/modules/yardstick/config/vendors/ignite-jdbc-thin-select.properties new file mode 100644 index 0000000..640f54b --- /dev/null +++ b/modules/yardstick/config/vendors/ignite-jdbc-thin-select.properties @@ -0,0 +1,109 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Thin JDBC driver benchmarks for select and select with join queries. +# + +now0=`date +'%H%M%S'` + +# JVM options. +JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false" + +# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. +JVM_OPTS=${JVM_OPTS}" \ +-Xms8g \ +-Xmx8g \ +-Xloggc:./gc${now0}.log \ +-XX:+PrintGCDetails \ +-verbose:gc \ +-XX:+UseParNewGC \ +-XX:+UseConcMarkSweepGC \ +-XX:+PrintGCDateStamps \ +" + +#Ignite version +ver="RELEASE-" + +# List of default probes. +# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe + +# Packages where the specified benchmark is searched by reflection mechanism. +BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick + +# Flag which indicates to restart the servers before every benchmark execution. +RESTART_SERVERS=true + +# Probe point writer class name. +# BENCHMARK_WRITER= + +# This benchmark is designed to use only one node. +SERVER_HOSTS=localhost +DRIVER_HOSTS=localhost + +# Remote username. +# REMOTE_USER= + +# Number of nodes, used to wait for the specified number of nodes to start. +nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} | tr ',' '\n' | wc -l`)) + +# Warmup. +w=60 + +# Duration. +d=300 + +# Threads count. +t=1 + +inmemCfg="${SCRIPT_DIR}/../config/vendors/ignite-config-inmemory.xml" + +persistCfg="${SCRIPT_DIR}/../config/vendors/ignite-config-persistence.xml" + +thinUrl="jdbc:ignite:thin://localhost/" +v2Url="jdbc:ignite:cfg://cache=fakeCache@config/ignite-jdbc-config.xml" + +commonParams="\ + -nn ${nodesNum} \ + -w ${w} -d ${d} \ + -cl --clientNodesAfterId -1 \ + -t ${t} \ + -sn IgniteNode" +# Run configuration which contains all benchmarks. +# Note that each benchmark is set to run for 300 seconds (5 min) with warm-up set to 60 seconds (1 minute). +CONFIGS="\ + ${commonParams} -cfg ${inmemCfg} -jdbc ${thinUrl} -dn SelectBySalaryBenchmark -ds ${ver}select-idx-field-jdbc-thin-inmemory --sqlRange 1000 --range 1000000, \ + ${commonParams} -cfg ${inmemCfg} -jdbc ${v2Url} -dn SelectBySalaryBenchmark -ds ${ver}select-idx-field-jdbc-v2-inmemory --sqlRange 1000 --range 1000000, \ + ${commonParams} -cfg ${persistCfg} -jdbc ${thinUrl} -dn SelectBySalaryBenchmark -ds ${ver}select-idx-field-jdbc-thin-persistence --sqlRange 1000 --range 1000000, \ + ${commonParams} -cfg ${persistCfg} -jdbc ${v2Url} -dn SelectBySalaryBenchmark -ds ${ver}select-idx-field-jdbc-v2-persistence --sqlRange 1000 --range 1000000, \ + \ + ${commonParams} -cfg ${inmemCfg} -jdbc ${thinUrl} -dn SelectBySalaryWithJoinBenchmark -ds ${ver}select-idx-field-join-jdbc-thin-inmemory --sqlRange 1000 --range 1000000, \ + ${commonParams} -cfg ${inmemCfg} -jdbc ${v2Url} -dn SelectBySalaryWithJoinBenchmark -ds ${ver}select-idx-field-join-jdbc-v2-inmemory --sqlRange 1000 --range 1000000, \ + ${commonParams} -cfg ${persistCfg} -jdbc ${thinUrl} -dn SelectBySalaryWithJoinBenchmark -ds ${ver}select-idx-field-join-jdbc-thin-persistence --sqlRange 1000 --range 1000000, \ + ${commonParams} -cfg ${persistCfg} -jdbc ${v2Url} -dn SelectBySalaryWithJoinBenchmark -ds ${ver}select-idx-field-join-jdbc-v2-persistence --sqlRange 1000 --range 1000000, \ + \ + ${commonParams} -cfg ${inmemCfg} -jdbc ${thinUrl} -dn SelectByPkBenchmark -ds ${ver}select-pk-jdbc-thin-inmemory --range 1000000, \ + ${commonParams} -cfg ${inmemCfg} -jdbc ${v2Url} -dn SelectByPkBenchmark -ds ${ver}select-pk-jdbc-v2-inmemory --range 1000000, \ + ${commonParams} -cfg ${persistCfg} -jdbc ${thinUrl} -dn SelectByPkBenchmark -ds ${ver}select-pk-jdbc-thin-persistence --range 1000000, \ + ${commonParams} -cfg ${persistCfg} -jdbc ${v2Url} -dn SelectByPkBenchmark -ds ${ver}select-pk-jdbc-v2-persistence --range 1000000, \ + \ + ${commonParams} -cfg ${inmemCfg} -jdbc ${thinUrl} -dn SelectByPkWithJoinBenchmark -ds ${ver}select-pk-join-jdbc-thin-inmemory --range 1000000,\ + ${commonParams} -cfg ${inmemCfg} -jdbc ${v2Url} -dn SelectByPkWithJoinBenchmark -ds ${ver}select-pk-join-jdbc-v2-inmemory --range 1000000,\ + ${commonParams} -cfg ${persistCfg} -jdbc ${thinUrl} -dn SelectByPkWithJoinBenchmark -ds ${ver}select-pk-join-jdbc-thin-persistence --range 1000000,\ + ${commonParams} -cfg ${persistCfg} -jdbc ${v2Url} -dn SelectByPkWithJoinBenchmark -ds ${ver}select-pk-join-jdbc-v2-persistence --range 1000000 \ + " http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/config/vendors/mysql-jdbc-select-all.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/vendors/mysql-jdbc-select-all.properties b/modules/yardstick/config/vendors/mysql-jdbc-select-all.properties new file mode 100644 index 0000000..ddec6ca --- /dev/null +++ b/modules/yardstick/config/vendors/mysql-jdbc-select-all.properties @@ -0,0 +1,91 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Benchmarks for select and select with join queries for mysql database. +# Queries in these benchmarks have no WHERE clause. +# + +now0=`date +'%H%M%S'` + +# JVM options. +JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false" + +# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. +JVM_OPTS=${JVM_OPTS}" \ +-Xms8g \ +-Xmx8g \ +-Xloggc:./gc${now0}.log \ +-XX:+PrintGCDetails \ +-verbose:gc \ +-XX:+UseParNewGC \ +-XX:+UseConcMarkSweepGC \ +-XX:+PrintGCDateStamps \ +" + +#Ignite version +ver="RELEASE-" + +# List of default probes. +# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe + +# Since time of each query is big, lets build probe point each 10 seconds. +BENCHMARK_BUILD_PROBE_POINT_INTERVAL=10000 + +# Packages where the specified benchmark is searched by reflection mechanism. +BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick + +# Flag which indicates to restart the servers before every benchmark execution. +RESTART_SERVERS=true + +# Probe point writer class name. +# BENCHMARK_WRITER= + +# We need no Ignite instances in this benchmark. +SERVER_HOSTS="" +DRIVER_HOSTS=localhost + +# Remote username. +# REMOTE_USER= + +# Warmup. +w=60 + +# Duration. +d=300 + +# Threads count. +t=1 + +mysqlUrl="jdbc:mysql://localhost/" + +commonParams="-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml \ + -nn 1 \ + -w ${w} -d ${d} \ + --clientNodesAfterId 0 \ + -t ${t} \ + -sn IgniteNode \ + --sqlRange 1000000 \ + --range 1000000" + +# Run configuration which contains all benchmarks. +# Note that each benchmark is set to run for 300 seconds (5 min) with warm-up set to 60 seconds (1 minute). +CONFIGS="\ + ${commonParams} -jdbc ${mysqlUrl} -dn ScanAllBenchmark -ds ${ver}select-all-jdbc-mysql, \ + ${commonParams} -jdbc ${mysqlUrl} -dn ScanAllWithJoinBenchmark -ds ${ver}select-all-join-jdbc-mysql \ +" http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/config/vendors/mysql-jdbc-select.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/vendors/mysql-jdbc-select.properties b/modules/yardstick/config/vendors/mysql-jdbc-select.properties new file mode 100644 index 0000000..d1dc9f3 --- /dev/null +++ b/modules/yardstick/config/vendors/mysql-jdbc-select.properties @@ -0,0 +1,86 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Benchmarks for select and select with join queries for mysql database. +# + +now0=`date +'%H%M%S'` + +# JVM options. +JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false" + +# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. +JVM_OPTS=${JVM_OPTS}" \ +-Xms8g \ +-Xmx8g \ +-Xloggc:./gc${now0}.log \ +-XX:+PrintGCDetails \ +-verbose:gc \ +-XX:+UseParNewGC \ +-XX:+UseConcMarkSweepGC \ +-XX:+PrintGCDateStamps \ +" + +#Ignite version +ver="RELEASE-" + +# List of default probes. +# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe + +# Packages where the specified benchmark is searched by reflection mechanism. +BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick + +# Flag which indicates to restart the servers before every benchmark execution. +RESTART_SERVERS=true + +# Probe point writer class name. +# BENCHMARK_WRITER= + +# We need no Ignite instances in this benchmark. +SERVER_HOSTS="" +DRIVER_HOSTS=localhost + +# Remote username. +# REMOTE_USER= + +# Warmup. +w=60 + +# Duration. +d=300 + +# Threads count. +t=1 + +mysqlUrl="jdbc:mysql://localhost/" + +commonParams="-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml \ + -nn 1 \ + -w ${w} -d ${d} \ + --clientNodesAfterId 0 \ + -t ${t} \ + -sn IgniteNode" +# Run configuration which contains all benchmarks. +# Note that each benchmark is set to run for 300 seconds (5 min) with warm-up set to 60 seconds (1 minute). +CONFIGS="\ + ${commonParams} -jdbc ${mysqlUrl} -dn SelectBySalaryBenchmark -ds ${ver}select-idx-field-jdbc-mysql --sqlRange 1000 --range 1000000, \ + ${commonParams} -jdbc ${mysqlUrl} -dn SelectBySalaryWithJoinBenchmark -ds ${ver}select-idx-field-join-jdbc-mysql --sqlRange 1000 --range 1000000,\ + ${commonParams} -jdbc ${mysqlUrl} -dn SelectByPkBenchmark -ds ${ver}select-pk-jdbc-mysql --range 1000000, \ + ${commonParams} -jdbc ${mysqlUrl} -dn SelectByPkWithJoinBenchmark -ds ${ver}select-pk-join-jdbc-mysql --range 1000000 \ +" http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/config/vendors/postgre-jdbc-select-all.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/vendors/postgre-jdbc-select-all.properties b/modules/yardstick/config/vendors/postgre-jdbc-select-all.properties new file mode 100644 index 0000000..6bc635f --- /dev/null +++ b/modules/yardstick/config/vendors/postgre-jdbc-select-all.properties @@ -0,0 +1,90 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Benchmarks for select and select with join queries for mysql database. +# Queries in these benchmarks have no WHERE clause. +# + +now0=`date +'%H%M%S'` + +# JVM options. +JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false" + +# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. +JVM_OPTS=${JVM_OPTS}" \ +-Xms8g \ +-Xmx8g \ +-Xloggc:./gc${now0}.log \ +-XX:+PrintGCDetails \ +-verbose:gc \ +-XX:+UseParNewGC \ +-XX:+UseConcMarkSweepGC \ +-XX:+PrintGCDateStamps \ +" + +#Ignite version +ver="RELEASE-" + +# List of default probes. +# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe + +# Since time of each query is big, lets build probe point each 10 seconds. +BENCHMARK_BUILD_PROBE_POINT_INTERVAL=10000 + +# Packages where the specified benchmark is searched by reflection mechanism. +BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick + +# Flag which indicates to restart the servers before every benchmark execution. +RESTART_SERVERS=true + +# Probe point writer class name. +# BENCHMARK_WRITER= + +# We need no Ignite instances in this benchmark. +SERVER_HOSTS="" +DRIVER_HOSTS=localhost + +# Remote username. +# REMOTE_USER= + +# Warmup. +w=60 + +# Duration. +d=300 + +# Threads count. +t=1 + +pgUrl="jdbc:postgresql://localhost/" + +commonParams="-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml \ + -nn 1 \ + -w ${w} -d ${d} \ + --clientNodesAfterId 0 \ + -t ${t} \ + -sn IgniteNode \ + --sqlRange 1000000 \ + --range 1000000" +# Run configuration which contains all benchmarks. +# Note that each benchmark is set to run for 300 seconds (5 min) with warm-up set to 60 seconds (1 minute). +CONFIGS="\ + ${commonParams} -jdbc ${pgUrl} -dn ScanAllBenchmark -ds ${ver}select-all-jdbc-postgresql , \ + ${commonParams} -jdbc ${pgUrl} -dn ScanAllWithJoinBenchmark -ds ${ver}select-all-join-postgresql \ +" http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/config/vendors/postgre-jdbc-select.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/vendors/postgre-jdbc-select.properties b/modules/yardstick/config/vendors/postgre-jdbc-select.properties new file mode 100644 index 0000000..7189eaf --- /dev/null +++ b/modules/yardstick/config/vendors/postgre-jdbc-select.properties @@ -0,0 +1,86 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Benchmarks for select and select with join queries for mysql database. +# + +now0=`date +'%H%M%S'` + +# JVM options. +JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false" + +# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. +JVM_OPTS=${JVM_OPTS}" \ +-Xms8g \ +-Xmx8g \ +-Xloggc:./gc${now0}.log \ +-XX:+PrintGCDetails \ +-verbose:gc \ +-XX:+UseParNewGC \ +-XX:+UseConcMarkSweepGC \ +-XX:+PrintGCDateStamps \ +" + +#Ignite version +ver="RELEASE-" + +# List of default probes. +# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe + +# Packages where the specified benchmark is searched by reflection mechanism. +BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick + +# Flag which indicates to restart the servers before every benchmark execution. +RESTART_SERVERS=true + +# Probe point writer class name. +# BENCHMARK_WRITER= + +# We need no Ignite instances in this benchmark. +SERVER_HOSTS="" +DRIVER_HOSTS=localhost + +# Remote username. +# REMOTE_USER= + +# Warmup. +w=60 + +# Duration. +d=300 + +# Threads count. +t=1 + +pgUrl="jdbc:postgresql://localhost/" + +commonParams="-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml \ + -nn 1 \ + -w ${w} -d ${d} \ + --clientNodesAfterId 0 \ + -t ${t} \ + -sn IgniteNode" +# Run configuration which contains all benchmarks. +# Note that each benchmark is set to run for 300 seconds (5 min) with warm-up set to 60 seconds (1 minute). +CONFIGS="\ + ${commonParams} -jdbc ${pgUrl} -dn SelectBySalaryBenchmark -ds ${ver}select-idx-field-jdbc-postgresql --sqlRange 1000 --range 1000000, \ + ${commonParams} -jdbc ${pgUrl} -dn SelectBySalaryWithJoinBenchmark -ds ${ver}select-idx-field-join-jdbc-postgresql --sqlRange 1000 --range 1000000,\ + ${commonParams} -jdbc ${pgUrl} -dn SelectByPkBenchmark -ds ${ver}select-pk-jdbc-postgresql --range 1000000, \ + ${commonParams} -jdbc ${pgUrl} -dn SelectByPkWithJoinBenchmark -ds ${ver}select-pk-join-jdbc-postgresql --range 1000000, \ +" http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/AbstractJdbcBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/AbstractJdbcBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/AbstractJdbcBenchmark.java index 7d5b940..5511255 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/AbstractJdbcBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/AbstractJdbcBenchmark.java @@ -41,6 +41,12 @@ public abstract class AbstractJdbcBenchmark extends IgniteAbstractBenchmark { /** All {@link Connection}s associated with threads. */ private final List<Connection> threadConnections = new ArrayList<>(); + /** + * If JDBC thin driver url starts with this string means that benchmark code should find node to connect. + * See {@link #findThinAddress()}. + */ + public static final String JDBC_THIN_AUTO_FIND_PREFIX = JdbcThinUtils.URL_PREFIX + "auto.find"; + /** JDBC URL. */ protected String url; @@ -70,8 +76,9 @@ public abstract class AbstractJdbcBenchmark extends IgniteAbstractBenchmark { ignite().cluster().active(true); if (url == null) { - if (args.jdbcUrl().startsWith(JdbcThinUtils.URL_PREFIX)) { + if (args.jdbcUrl().startsWith(JDBC_THIN_AUTO_FIND_PREFIX)) { String addr = findThinAddress(); + url = JdbcThinUtils.URL_PREFIX + addr + '/'; } else http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/BaseSelectRangeBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/BaseSelectRangeBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/BaseSelectRangeBenchmark.java new file mode 100644 index 0000000..a93df6f --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/BaseSelectRangeBenchmark.java @@ -0,0 +1,342 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.yardstick.jdbc.vendors; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ThreadLocalRandom; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.yardstick.IgniteBenchmarkArguments; +import org.apache.ignite.yardstick.jdbc.AbstractJdbcBenchmark; +import org.yardstickframework.BenchmarkConfiguration; + +import static org.yardstickframework.BenchmarkUtils.println; + +/** + * Base benchmark for sql select operation. Designed to compare Ignite and other DBMSes. Children specify what exactly + * query gets executed and how parameters are filled. + */ +public abstract class BaseSelectRangeBenchmark extends AbstractJdbcBenchmark { + /** Factory that hides all sql queries. */ + protected QueryFactory queries; + + /** Number of persons in that times greater than organizations. */ + private static final int ORG_TO_PERS_FACTOR = 10; + + /** Size in rows of jdbc batch. Used during database population. */ + private static final int BATCH_SIZE = 10_000; + + /** Resources that should be closed. For example, opened thread local statements. */ + private List<AutoCloseable> toClose = Collections.synchronizedList(new ArrayList<>()); + + /** Thread local select statement. */ + protected ThreadLocal<PreparedStatement> select = new ThreadLocal<PreparedStatement>() { + @Override protected PreparedStatement initialValue() { + try { + Connection locConn = conn.get(); + + PreparedStatement sel = locConn.prepareStatement(testedSqlQuery()); + + toClose.add(sel); + + return sel; + } + catch (SQLException e) { + throw new RuntimeException("Can't create thread local statement.", e); + } + } + }; + + /** + * Children implement this method to specify what statement to prepare. During benchmark run, this prepared + * statement gets executed. Parameters are filled by {@link #fillTestedQueryParams(PreparedStatement)} method. + * + * @return sql query. Possibly with parameters. + */ + protected abstract String testedSqlQuery(); + + /** + * Children implement this method to specify how to generate parameters of tested query. + * + * See {@link #testedSqlQuery()}. + */ + protected abstract void fillTestedQueryParams(PreparedStatement select) throws SQLException; + + /** {@inheritDoc} */ + @Override protected void setupData() throws Exception { + // Don't use default tables. + // Instead we are able to use ignite instance to check cluster, before this instance gets closed. + Collection<ClusterNode> srvNodes = ignite().cluster().forServers().nodes(); + + if (srvNodes.size() > 1) { + throw new IllegalStateException("This benchmark is designed to no more than one server (data) node. " + + "Currently cluster contains " + srvNodes.size() + " server nodes : " + srvNodes); + } + } + + /** {@inheritDoc} */ + @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { + super.setUp(cfg); + + queries = new QueryFactory(); + + Connection conn0 = conn.get(); + + executeUpdate(conn0, queries.dropPersonIfExist()); + executeUpdate(conn0, queries.dropOrgIfExist()); + + executeUpdate(conn0, queries.createPersonTab()); + executeUpdate(conn0, queries.createOrgTab()); + + executeUpdate(conn0, queries.createSalaryIdx()); + executeUpdate(conn0, queries.createOrgIdIdx()); + + executeUpdate(conn0, queries.beforeLoad()); + + boolean oldAutoCommit = conn0.getAutoCommit(); + + trySetAutoCommit(conn0, false); + + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + + long orgRng = args.range() / ORG_TO_PERS_FACTOR; + + println(cfg, "Populating Organization table."); + + try (PreparedStatement insOrg = conn0.prepareStatement(queries.insertIntoOrganization())) { + long percent = 0; + + for (long orgId = 0; orgId < orgRng; orgId++) { + insOrg.setLong(1, orgId); + insOrg.setString(2, "organization#" + orgId); + + insOrg.addBatch(); + + if ((orgId + 1) % BATCH_SIZE == 0 || (orgId + 1) == orgRng) { + insOrg.executeBatch(); + + long newPercent = (orgId + 1) * 100 / orgRng; + + if (percent != newPercent) { + percent = newPercent; + + println(cfg, (orgId + 1) + " out of " + orgRng + " rows have been uploaded " + + "(" + percent + "%)."); + } + } + } + } + + println(cfg, "Populating Person table."); + + try (PreparedStatement insPers = conn0.prepareStatement(queries.insertIntoPerson())) { + long percent = 0; + + for (long persId = 0; persId < args.range(); persId++) { + long orgId = rnd.nextLong(orgRng); + + fillPersonArgs(insPers, persId, orgId).addBatch(); + + if ((persId + 1) % BATCH_SIZE == 0) { + insPers.executeBatch(); + + long newPercent = (persId + 1) * 100 / args.range(); + + if (percent != newPercent) { + percent = newPercent; + + println(cfg, (persId + 1) + " out of " + args.range() + " rows have been uploaded " + + "(" + percent + "%)."); + } + } + } + } + + trySetAutoCommit(conn0, oldAutoCommit); + + executeUpdate(conn0, queries.afterLoad()); + + println(cfg, "Database have been populated."); + + String explainSql = "EXPLAIN " + testedSqlQuery(); + + try (PreparedStatement expStat = conn0.prepareStatement(explainSql);) { + fillTestedQueryParams(expStat); + + try(ResultSet explain = expStat.executeQuery()) { + println(cfg, "Explain query " + explainSql + " result:"); + + println(cfg, tableToString(explain)); + } + } + } + + /** + * Prints result set as formatted table. + * + * @param rs result set that represets table. + */ + private static String tableToString(ResultSet rs) throws SQLException { + StringBuilder buf = new StringBuilder(); + + for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { + String cell = String.format("%-20s", rs.getMetaData().getColumnName(i)); + + buf.append(cell).append("\t"); + } + + buf.append("\n"); + + while (rs.next()) { + for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { + String cell = String.format("%-20s", rs.getString(i)); + + buf.append(cell).append("\t"); + } + + buf.append("\t"); + } + + return buf.toString(); + } + + /** + * Set auto commit if it is supported. Log warning otherwise. + * + * @param conn Set auto commit mode to this connection. + * @param autocommit Autocommit mode parameter value. + */ + private void trySetAutoCommit(Connection conn, boolean autocommit) throws SQLException { + try { + conn.setAutoCommit(autocommit); + } + catch (SQLFeatureNotSupportedException ignored) { + println(cfg, "Failed to set auto commit to " + autocommit + " because it is unsupported operation, " + + "will just ignore it."); + } + } + + /** + * Perform sql update operation on specified jdbc connection. + * + * @param c jdbc connection to use. + * @param sql text of the update query. + * @throws SQLException on error. + */ + static void executeUpdate(Connection c, String sql) throws SQLException { + if (F.isEmpty(sql)) + return; + + try (Statement upd = c.createStatement()) { + upd.executeUpdate(sql); + } + } + + /** + * Given query that has 2 parameters which should be values of salary, according to the data model. This method + * generates range with a random begin point and fixed width({@link IgniteBenchmarkArguments#sqlRange()}) and fills + * prepared statement, that represents such query, with values : range begin and range end. + * + * @param selectBySalary Prepared statement, representing select with filter by salary field. + */ + protected void fillRandomSalaryRange(PreparedStatement selectBySalary) throws SQLException { + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + + long minId = rnd.nextLong(args.range() - args.sqlRange() + 1); + long maxId = minId + args.sqlRange() - 1; + + long minSalary = minId * 1000; + long maxSalary = maxId * 1000; + + selectBySalary.setLong(1, minSalary); + selectBySalary.setLong(2, maxSalary); + } + + /** + * Template method for benchmark. Executes thread-local PreparedStatement. Children are specifying what query with + * what parameters to execute and how to fill it's parameters. + */ + @Override public final boolean test(Map<Object, Object> map) throws Exception { + PreparedStatement select0 = select.get(); + + fillTestedQueryParams(select0); + + try (ResultSet res = select0.executeQuery()) { + readResults(res); + } + + return true; + } + + /** + * Reads all the specified result set. Checks that result size is as expected. + * + * @param qryRes result set of executed select. + */ + private void readResults(ResultSet qryRes) throws SQLException { + long rsCnt = 0; + + while (qryRes.next()) + rsCnt++; + + if (rsCnt != args.sqlRange()) + throw new AssertionError("Server returned wrong number of lines: " + + "[expected=" + args.sqlRange() + ", actual=" + rsCnt + "]."); + } + + /** {@inheritDoc} */ + @Override public void tearDown() throws Exception { + try { + executeUpdate(conn.get(), queries.dropPersonIfExist()); + executeUpdate(conn.get(), queries.dropOrgIfExist()); + + for (AutoCloseable stmt : toClose) + stmt.close(); + } + finally { + super.tearDown(); + } + } + + /** + * Generate Person record and fill with it specified statement. + * + * @param insPers PreparedStatement which parametets to fill. + * @param id person's id. + * @param orgId id of organization, this person associated with. + */ + static PreparedStatement fillPersonArgs(PreparedStatement insPers, long id, long orgId) throws SQLException { + insPers.setLong(1, id); + insPers.setLong(2, orgId); + insPers.setString(3, "firstName" + id); + insPers.setString(4, "lastName" + id); + insPers.setLong(5, id * 1000); + + return insPers; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/QueryFactory.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/QueryFactory.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/QueryFactory.java new file mode 100644 index 0000000..1a8a40c --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/QueryFactory.java @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.yardstick.jdbc.vendors; + +/** + * Creates queries. Currently queries are written in SQL dialect that is common to Ignite SQL, MySql and PostgreSQL. + */ +public class QueryFactory { + /** Query that creates Person table. */ + public String createPersonTab() { + return "CREATE TABLE PUBLIC.PERSON (" + + "id BIGINT PRIMARY KEY, " + + "org_id BIGINT, " + + "first_name VARCHAR(255), " + + "last_name VARCHAR(255), " + + "salary BIGINT);"; + } + + /** Query that creates Organization table. */ + public String createOrgTab() { + return "CREATE TABLE PUBLIC.ORGANIZATION (id BIGINT PRIMARY KEY, name VARCHAR(255));"; + } + + /** Query that creates index on 'salary' field. */ + public String createSalaryIdx() { + return "CREATE INDEX sal_idx ON PUBLIC.PERSON(salary);"; + } + + /** Query that creates index on Person.org_id to have fast join query. */ + public String createOrgIdIdx() { + return "CREATE INDEX org_id_idx ON PUBLIC.PERSON(org_id)"; + } + + /** Query that drops Person table. */ + public String dropPersonIfExist() { + return "DROP TABLE IF EXISTS PUBLIC.PERSON;"; + } + + /** Query that drops Person table. */ + public String dropOrgIfExist() { + return "DROP TABLE IF EXISTS PUBLIC.ORGANIZATION;"; + } + + /** Query to execute before data upload. */ + public String beforeLoad() { + return null; + } + + /** Query to execute after data upload. */ + public String afterLoad() { + return null; + } + + /** + * Query that fetches persons which salaries are in range. Range borders are specified as parameters of + * PreparedStatement. + */ + public String selectPersonsWithSalaryBetween() { + return "SELECT * FROM PUBLIC.PERSON WHERE SALARY BETWEEN ? AND ?"; + } + + /** Simple select query that fetches person with specified Person.id. */ + public String selectPersonsByPK() { + return "SELECT * FROM PUBLIC.PERSON WHERE id = ? ;"; + } + + /** Query that inserts new Person record. Has 5 jdbc parameters - fields of the Person. */ + public String insertIntoPerson() { + return "INSERT INTO PUBLIC.PERSON (id, org_id, first_name, last_name, salary) values (?, ?, ?, ?, ?)"; + } + + /** Query that inserts new Organization record. Has 2 jdbc parameters - org id and org name. */ + public String insertIntoOrganization() { + return "INSERT INTO PUBLIC.ORGANIZATION (id, name) VALUES (?, ?);"; + } + + /** + * Query that fetches info about persons and theirs organizations for that persons who has salary in specified + * range. + */ + public String selectPersonsJoinOrgWhereSalary() { + return "SELECT p.id, p.org_id, p.first_name, p.last_name, p.salary, o.name " + + "FROM PUBLIC.PERSON p " + + "INNER JOIN PUBLIC.ORGANIZATION o " + + "ON p.org_id = o.id " + + "WHERE salary BETWEEN ? AND ?;"; + } + + /** + * Query that fetches info about person with specified Person.id and it's organization. + */ + public String selectPersonsJoinOrgWherePersonPK() { + return "SELECT p.id, p.org_id, p.first_name, p.last_name, p.salary, o.name " + + "FROM PUBLIC.PERSON p " + + "INNER JOIN PUBLIC.ORGANIZATION o " + + "ON p.org_id = o.id " + + "WHERE p.id = ?;"; + } + + /** Query that fetches all ids from Person table. Has no parameters. */ + public String selectAllPersons() { + return "SELECT * FROM PUBLIC.PERSON;"; + } + + /** Query that fetches all records about all persons with info about theirs organizations. */ + public String selectAllPersonsJoinOrg() { + return "SELECT p.id, p.org_id, p.first_name, p.last_name, p.salary, o.name " + + "FROM PUBLIC.PERSON p " + + "INNER JOIN PUBLIC.ORGANIZATION o " + + "ON p.org_id = o.id;"; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/ScanAllBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/ScanAllBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/ScanAllBenchmark.java new file mode 100644 index 0000000..e781fab --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/ScanAllBenchmark.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.yardstick.jdbc.vendors; + +import java.sql.PreparedStatement; +import java.sql.SQLException; +import org.apache.ignite.yardstick.IgniteBenchmarkArguments; + +/** + * Benchmark that fetches all the rows from Person table. Specify in the properties file {@link + * IgniteBenchmarkArguments#sqlRange()} to be equal to whole Person table size ({@link + * IgniteBenchmarkArguments#range()}). + */ +public class ScanAllBenchmark extends BaseSelectRangeBenchmark { + /** {@inheritDoc} */ + @Override protected void fillTestedQueryParams(PreparedStatement select) throws SQLException { + //No-op, query doesn't have parameters to fill. + } + + /** {@inheritDoc} */ + @Override protected String testedSqlQuery() { + return queries.selectAllPersons(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/ScanAllWithJoinBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/ScanAllWithJoinBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/ScanAllWithJoinBenchmark.java new file mode 100644 index 0000000..0e67483 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/ScanAllWithJoinBenchmark.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.yardstick.jdbc.vendors; + +import java.sql.PreparedStatement; +import java.sql.SQLException; +import org.apache.ignite.yardstick.IgniteBenchmarkArguments; + +/** + * Benchmark that fetches all the rows from table of Person inner join Organization table. Specify in the properties + * file {@link IgniteBenchmarkArguments#sqlRange()} to be equal to whole Person table size ({@link + * IgniteBenchmarkArguments#range()}) since Person table contains more rows than Organization. + */ +public class ScanAllWithJoinBenchmark extends BaseSelectRangeBenchmark { + /** {@inheritDoc} */ + @Override protected void fillTestedQueryParams(PreparedStatement select) throws SQLException { + //No-op, query doesn't have parameters to fill. + } + + /** {@inheritDoc} */ + @Override protected String testedSqlQuery() { + return queries.selectAllPersonsJoinOrg(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectByPkBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectByPkBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectByPkBenchmark.java new file mode 100644 index 0000000..55092f5 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectByPkBenchmark.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.yardstick.jdbc.vendors; + +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.concurrent.ThreadLocalRandom; + +/** + * Benchmark that performs selects with filter by primary key field. + */ +public class SelectByPkBenchmark extends BaseSelectRangeBenchmark { + /** {@inheritDoc} */ + @Override protected void fillTestedQueryParams(PreparedStatement select) throws SQLException { + long persId = ThreadLocalRandom.current().nextLong(args.range()); + + select.setLong(1, persId); + } + + /** {@inheritDoc} */ + @Override protected String testedSqlQuery() { + return queries.selectPersonsByPK(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectByPkWithJoinBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectByPkWithJoinBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectByPkWithJoinBenchmark.java new file mode 100644 index 0000000..fe42d22 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectByPkWithJoinBenchmark.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.yardstick.jdbc.vendors; + +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.concurrent.ThreadLocalRandom; + +/** + * Benchmark that performs selects with filter by primary key field with join on Organization table. + */ +public class SelectByPkWithJoinBenchmark extends BaseSelectRangeBenchmark { + /** {@inheritDoc} */ + @Override protected void fillTestedQueryParams(PreparedStatement select) throws SQLException { + long persId = ThreadLocalRandom.current().nextLong(args.range()); + + select.setLong(1, persId); + } + + /** {@inheritDoc} */ + @Override protected String testedSqlQuery() { + return queries.selectPersonsJoinOrgWherePersonPK(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectBySalaryBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectBySalaryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectBySalaryBenchmark.java new file mode 100644 index 0000000..d4a7b6a --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectBySalaryBenchmark.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.yardstick.jdbc.vendors; + +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * Benchmark that performs select with filter by 'salary' field. + */ +public class SelectBySalaryBenchmark extends BaseSelectRangeBenchmark { + /** {@inheritDoc} */ + @Override protected void fillTestedQueryParams(PreparedStatement select) throws SQLException { + fillRandomSalaryRange(select); + } + + /** {@inheritDoc} */ + @Override protected String testedSqlQuery() { + return queries.selectPersonsWithSalaryBetween(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectBySalaryWithJoinBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectBySalaryWithJoinBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectBySalaryWithJoinBenchmark.java new file mode 100644 index 0000000..1fc172e --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/vendors/SelectBySalaryWithJoinBenchmark.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.yardstick.jdbc.vendors; + +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * Benchmark that performs select with filter by 'salary' field and inner join with Organization table. + */ +public class SelectBySalaryWithJoinBenchmark extends BaseSelectRangeBenchmark { + /** {@inheritDoc} */ + @Override protected void fillTestedQueryParams(PreparedStatement select) throws SQLException { + fillRandomSalaryRange(select); + } + + /** {@inheritDoc} */ + @Override protected String testedSqlQuery() { + return queries.selectPersonsJoinOrgWhereSalary(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/383d8b2a/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index 455070a..841a45b 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -99,13 +99,13 @@ <lz4.version>1.5.0</lz4.version> <maven.bundle.plugin.version>3.5.0</maven.bundle.plugin.version> <mockito.version>1.10.19</mockito.version> - <mysql.connector.version>5.1.39</mysql.connector.version> + <mysql.connector.version>8.0.13</mysql.connector.version> <netlibjava.version>1.1.2</netlibjava.version> <oro.bundle.version>2.0.8_6</oro.bundle.version> <osgi.core.version>5.0.0</osgi.core.version> <osgi.enterprise.version>5.0.0</osgi.enterprise.version> <paho.version>1.0.2</paho.version> - <postgres.connector.version>9.4.1208.jre7</postgres.connector.version> + <postgres.connector.version>42.2.5.jre7</postgres.connector.version> <rocketmq.version>4.3.0</rocketmq.version> <scala210.jline.version>2.10.7</scala210.jline.version> <scala210.library.version>2.10.7</scala210.library.version>