SQLize
Online
/
PHPize Online
/
SQLtest Online
A
A
A
Share
Donate
Blog
Popular
Donate
A
A
A
Share
Blog
Popular
SQLize.online is a free online SQL environment for quickly running, experimenting with and sharing code.
You can run your SQL code on top of the most popular RDBMS including MySQL, MariaDB, SQLite, PostgreSQL, Oracle and Microsoft SQL Server.
SQL code:
Upload
Copy
Format
Clear
CREATE EXTENSION IF NOT EXISTS citext; RESET ALL; SET max_parallel_workers_per_gather = 0; SET work_mem = '256MB'; DROP TABLE IF EXISTS test_c_collation, test_usual, test_icu, test_insensitive, test_citext; CREATE COLLATION IF NOT EXISTS case_insensitive ( provider = icu, locale = 'und-u-ks-level2', deterministic = false ); CREATE OR REPLACE FUNCTION random_text(length integer) RETURNS text LANGUAGE sql AS $function$ WITH r(n, rn) AS ( SELECT n, (random() * 51)::int FROM generate_series(1, $1) AS g(n) ) SELECT string_agg(chr(ascii('A') + CASE WHEN rn < 26 THEN rn ELSE rn + 6 END), '' ORDER BY n) FROM r; $function$; CREATE UNLOGGED TABLE test_c_collation ( id bigint GENERATED ALWAYS AS IDENTITY, val text NOT NULL COLLATE "C" ); INSERT INTO test_c_collation(val) SELECT random_text(40) FROM generate_series(1, 10000) AS g(n); ALTER TABLE test_c_collation ADD PRIMARY KEY (id); CREATE UNLOGGED TABLE test_usual ( id bigint GENERATED ALWAYS AS IDENTITY, val text NOT NULL ); INSERT INTO test_usual(val) SELECT val FROM test_c_collation; ALTER TABLE test_usual ADD PRIMARY KEY (id); CREATE UNLOGGED TABLE test_icu ( id bigint GENERATED ALWAYS AS IDENTITY, val text NOT NULL COLLATE "ru-x-icu" ); INSERT INTO test_icu(val) SELECT val FROM test_c_collation; ALTER TABLE test_icu ADD PRIMARY KEY (id); CREATE UNLOGGED TABLE test_insensitive ( id bigint GENERATED ALWAYS AS IDENTITY, val text NOT NULL COLLATE "case_insensitive" ); INSERT INTO test_insensitive(val) SELECT val FROM test_c_collation; ALTER TABLE test_insensitive ADD PRIMARY KEY (id); CREATE UNLOGGED TABLE test_citext ( id bigint GENERATED ALWAYS AS IDENTITY, val citext NOT NULL ); INSERT INTO test_citext(val) SELECT val FROM test_c_collation; ALTER TABLE test_citext ADD PRIMARY KEY (id); -------------------------------------------------------------------------------- VACUUM ANALYZE test_c_collation, test_usual, test_icu, test_insensitive, test_citext; -------------------------------------------------------------------------------- SELECT d.datname AS "Name", pg_catalog.pg_encoding_to_char(d.encoding) AS "Encoding", d.datcollate AS "Collate", d.datctype AS "Ctype", d.daticulocale AS "ICU Locale", CASE d.datlocprovider WHEN 'c' THEN 'libc' WHEN 'i' THEN 'icu' END AS "Locale Provider" FROM pg_catalog.pg_database AS d WHERE d.datname = current_database(); -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_c_collation ORDER BY val; END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; -------------------------------------------------------------------------------- DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_usual ORDER BY val; END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; -------------------------------------------------------------------------------- DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_icu ORDER BY val; END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; -------------------------------------------------------------------------------- DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_insensitive ORDER BY val; END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; -------------------------------------------------------------------------------- DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_citext ORDER BY val; END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- DROP TABLE IF EXISTS test_search_c, test_search_usual, test_search_icu, test_search_insensitive, test_search_citext; CREATE UNLOGGED TABLE test_search_c ( val text NOT NULL COLLATE "C" ); INSERT INTO test_search_c(val) SELECT val FROM test_c_collation LIMIT 5000; INSERT INTO test_search_c(val) SELECT random_text(40) FROM generate_series(1, 5000) AS g(n); CREATE UNLOGGED TABLE test_search_usual ( val text NOT NULL ); INSERT INTO test_search_usual(val) SELECT val FROM test_search_c; CREATE UNLOGGED TABLE test_search_icu ( val text NOT NULL COLLATE "ru-x-icu" ); INSERT INTO test_search_icu(val) SELECT val FROM test_search_c; CREATE UNLOGGED TABLE test_search_insensitive ( val text NOT NULL COLLATE "case_insensitive" ); INSERT INTO test_search_insensitive(val) SELECT val FROM test_search_c; CREATE UNLOGGED TABLE test_search_citext ( val citext NOT NULL ); INSERT INTO test_search_citext(val) SELECT val FROM test_search_c; -------------------------------------------------------------------------------- VACUUM ANALYZE test_search_c, test_search_usual, test_search_icu, test_search_insensitive, test_search_citext; -------------------------------------------------------------------------------- DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_search_c AS s WHERE EXISTS ( SELECT 1 FROM test_c_collation AS t WHERE t.val = s.val ); END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_search_usual AS s WHERE EXISTS ( SELECT 1 FROM test_usual AS t WHERE t.val = s.val ); END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_search_icu AS s WHERE EXISTS ( SELECT 1 FROM test_icu AS t WHERE t.val = s.val ); END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_search_insensitive AS s WHERE EXISTS ( SELECT 1 FROM test_insensitive AS t WHERE t.val = s.val ); END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_search_citext AS s WHERE EXISTS ( SELECT 1 FROM test_citext AS t WHERE t.val = s.val ); END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --- The same, but with indexes: CREATE INDEX ON test_c_collation(val); CREATE INDEX ON test_usual(val); CREATE INDEX ON test_icu(val); CREATE INDEX ON test_insensitive(val); CREATE INDEX ON test_citext(val); SET enable_hashjoin = off; SET enable_sort = off; -------------------------------------------------------------------------------- DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_search_c AS s WHERE EXISTS ( SELECT 1 FROM test_c_collation AS t WHERE t.val = s.val ); END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_search_usual AS s WHERE EXISTS ( SELECT 1 FROM test_usual AS t WHERE t.val = s.val ); END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_search_icu AS s WHERE EXISTS ( SELECT 1 FROM test_icu AS t WHERE t.val = s.val ); END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_search_insensitive AS s WHERE EXISTS ( SELECT 1 FROM test_insensitive AS t WHERE t.val = s.val ); END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed; DO $do$ BEGIN PERFORM set_config('my.start', clock_timestamp()::text, false); PERFORM * FROM test_search_citext AS s WHERE EXISTS ( SELECT 1 FROM test_citext AS t WHERE t.val = s.val ); END; $do$; SELECT EXTRACT(millisecond FROM clock_timestamp() - current_setting('my.start')::timestamptz) AS milliseconds_elapsed;
SQL
Server:
MariaDB 11.4
MariaDB 11.5
MariaDB 10
MariaDB 10 Sakila (ReadOnly)
MySQL 5.7
MySQL 5.7 Sakila (ReadOnly)
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
SQLite 3
SQLite 3 Preloaded
PostgreSQL 10 Bookings (ReadOnly)
PostgreSQL 11
PostgreSQL 12
PostgreSQL 13
PostgreSQL 14
PostgreSQL 15
MS SQL Server 2017
MS SQL Server 2019
MS SQL Server 2022
MS SQL Server 2022 AdventureWorks (ReadOnly)
Firebird 4.0
Firebird 4.0 (Employee)
Oracle Database 19c (HR)
Oracle Database 21c
Oracle Database 23c Free
SOQOL
Version
ER Diagram
Preserve result
Stuck with a problem?
Got Error?
Ask ChatGPT!
Result:
Copy
Clear