Skip to content

Instantly share code, notes, and snippets.

@felixge
Created January 19, 2020 10:59
Show Gist options
  • Save felixge/64086c200ad6dc03aadd8b2900434c7a to your computer and use it in GitHub Desktop.
Save felixge/64086c200ad6dc03aadd8b2900434c7a to your computer and use it in GitHub Desktop.
SET search_path=uuids;
DROP SCHEMA IF EXISTS uuids CASCADE;
CREATE SCHEMA uuids;
CREATE EXTENSION "uuid-ossp";
SELECT version();
CREATE TABLE uuids (
id UUID PRIMARY KEY
);
\timing
COPY (
SELECT uuid_generate_v1()
FROM generate_series(1, 100000000)
) TO '/tmp/uuid_v1.txt';
COPY (
SELECT uuid_generate_v4()
FROM generate_series(1, 100000000)
) TO '/tmp/uuid_v4.txt';
COPY uuids FROM '/tmp/uuid_v1.txt';
TRUNCATE uuids;
COPY uuids FROM '/tmp/uuid_v4.txt';
SET
psql:uuids.sql:2: NOTICE: drop cascades to 2 other objects
DETAIL: drop cascades to extension uuid-ossp
drop cascades to table uuids
DROP SCHEMA
CREATE SCHEMA
CREATE EXTENSION
version
-------------------------------------------------------------------------------------------------------------
PostgreSQL 11.6 on x86_64-apple-darwin16.7.0, compiled by Apple LLVM version 8.1.0 (clang-802.0.42), 64-bit
CREATE TABLE
Timing is on.
COPY 100000000
Time: 222028.092 ms (03:42.028)
COPY 100000000
Time: 270791.658 ms (04:30.792)
COPY 100000000
Time: 714026.714 ms (11:54.027)
TRUNCATE TABLE
Time: 753.993 ms
COPY 100000000
Time: 1553324.184 ms (25:53.324)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment