Created
August 20, 2022 00:54
-
-
Save georgewfraser/1401b8382bec3b2202ccfe4d12cfbfa8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- psql -d postgres -f 1.Generate.sql | |
drop table if exists source; | |
create table source as | |
select | |
x, | |
cast(random() as varchar) as a, | |
cast(random() as varchar) as b, | |
cast(random() as varchar) as c, | |
cast(random() as varchar) as d, | |
cast(random() as varchar) as e, | |
cast(random() as varchar) as f, | |
cast(random() as varchar) as g, | |
cast(random() as varchar) as h, | |
cast(random() as varchar) as i, | |
cast(random() as varchar) as j | |
from generate_series(1, 5000000, 1) as x; | |
select count(*) from source; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- time psql -d postgres -f 2.Paging.sql > output.txt | |
begin; | |
set transaction isolation level read committed; | |
declare page_cursor cursor for select * from source; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
fetch 100000 from page_cursor; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment