Skip to content

Instantly share code, notes, and snippets.

@depaolim
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save depaolim/879a64256d146ddb0589 to your computer and use it in GitHub Desktop.
Save depaolim/879a64256d146ddb0589 to your computer and use it in GitHub Desktop.
drop view temp_data;
drop table temp_int;
drop table temp_uuid;
\timing
create view temp_data as
select
generate_series(1000001, 2000000) as key
;
select count(1) from temp_data;
create table temp_int (key integer);
insert into temp_int select key from temp_data;
alter table temp_int add PRIMARY KEY (key);
create table temp_uuid (key character varying(36));
insert into temp_uuid select uuid_in(md5(key::text)::cstring) from temp_data;
alter table temp_uuid add PRIMARY KEY (key);
analyze temp_int;
analyze temp_uuid;
select max(key) from temp_int;
select max(key) from temp_uuid;
select key from temp_int where key = (select min(key) from temp_int);
select key from temp_uuid where key = (select min(key) from temp_uuid);
\timing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment