Skip to content

Instantly share code, notes, and snippets.

View lukaseder's full-sized avatar

Lukas Eder lukaseder

View GitHub Profile
package org.jooq.test.benchmark;
import java.util.ArrayList;
import java.util.List;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Scope;
@lukaseder
lukaseder / Oracle.sql
Created December 18, 2017 08:29
Benchmarking DBMS_OUTPUT.GET_LINE[S] from PL/SQL
ALTER SYSTEM FLUSH SHARED_POOL;
ALTER SYSTEM FLUSH BUFFER_CACHE;
CREATE TABLE results (stmt NUMBER, i INTERVAL DAY TO SECOND);
DECLARE
v_ts TIMESTAMP WITH TIME ZONE;
v_repeat CONSTANT NUMBER := 50;
v_max CONSTANT NUMBER := 100;
@lukaseder
lukaseder / Oracle.java
Last active March 7, 2018 14:47
Benchmarking DBMS_OUTPUT.GET_LINE[S] from JDBC
import java.sql.Array;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.Types;
import java.util.Properties;
import java.util.stream.LongStream;
import java.util.stream.Stream;
@lukaseder
lukaseder / oracle-in-vs-union-all.sql
Created April 18, 2018 07:30
Oracle OR-connected IN lists vs large UNION ALL query
-- Copyright Data Geekery GmbH
--
-- Licensed 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,
@lukaseder
lukaseder / benchmark-update.sql
Created April 19, 2018 13:48
PL/SQL Benchmark Row-by-row Update vs FORALL vs Bulk Update
-- Copyright Data Geekery GmbH
--
-- Licensed 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,
@lukaseder
lukaseder / BenchmarkUpdate.java
Created April 19, 2018 13:58
JDBC Benchmark Row-by-row Update (with and without PreparedStatement reuse) vs Batch vs Bulk Update
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.Duration;
import java.time.Instant;
import java.util.Properties;
@lukaseder
lukaseder / compilation-error.txt
Created August 2, 2018 09:15
Average Java generics / type inference compilation error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:testCompile (default-testCompile) on project jool: Compilation failure
[ERROR] C:\Users\lukas\workspace\jOOL\jOOL\src\test\java\org\jooq\lambda\TupleTest.java:[225,27] error: no suitable method found for collectors(Collector<Object,CAP#1,Long>,Collector<Object,CAP#2,Optional<Object>>,Collector<Object,CAP#3,Optional<Object>>,Collector<T#1,CAP#4,Optional<T#1>>,Collector<T#2,CAP#5,Optional<T#2>>)
[ERROR] method Tuple.<T#3,A1#1,A2#1,A3#1,A4#1,A5#1,A6#1,A7#1,A8#1,A9#1,A10#1,A11#1,A12#1,A13#1,A14#1,A15#1,A16,D1#1,D2#1,D3#1,D4#1,D5#1,D6#1,D7#1,D8#1,D9#1,D10#1,D11#1,D12#1,D13#1,D14#1,D15#1,D16>collectors(Collector<? super T#3,A1#1,D1#1>,Collector<? super T#3,A2#1,D2#1>,Collector<? super T#3,A3#1,D3#1>,Collector<? super T#3,A4#1,D4#1>,Collector<? super T#3,A5#1,D5#1>,Collector<? super T#3,A6#1,D6#1>,Collector<? super T#3,A7#1,D7#1>,Collector<? super T#3,A8#1,D8#1>,Collector<? super T#3,A9#1,D9#1>,Collector<? super T#3,A10#1,D10#1>,
@lukaseder
lukaseder / plsql-vs-bulk-update.sql
Created September 26, 2018 12:43
PL/SQL row-by-row update vs bulk update
-- Copyright Data Geekery GmbH
--
-- Licensed 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,
@lukaseder
lukaseder / CallDefaultMethodThroughReflection.java
Created March 28, 2018 09:56
Correct Reflective Access to Interface Default Methods in Java 8, 9, 10
// Compile on JDK 9 or 10 with javac -source 1.8 -target 1.8 CallDefaultMethodThroughReflection.java
// Blog post here: https://blog.jooq.org/2018/03/28/correct-reflective-access-to-interface-default-methods-in-java-8-9-10
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@lukaseder
lukaseder / QOM.java
Created September 18, 2019 14:22
A simple proof of concept for a new Query Object Model in Java, using Immutables annotations
/*
* This work is dual-licensed
* - under the Apache Software License 2.0 (the "ASL")
* - under the jOOQ License and Maintenance Agreement (the "jOOQ License")
* =============================================================================
* You may choose which license applies to you:
*
* - If you're using this work with Open Source databases, you may choose
* either ASL or jOOQ License.
* - If you're using this work with at least one commercial database, you must