Created
June 26, 2013 21:02
-
-
Save pnorman/5871651 to your computer and use it in GitHub Desktop.
apidb tests on join vs cgimap cache speed
This file contains hidden or 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
-- tweak range and modulo value to get right number of nodes and changesets | |
select count(*) from (select distinct n.changeset_id from current_nodes n where n.id between | |
2329800000 and 2347300000 and n.id % 10 =0) as changesets; | |
select count(*) from current_nodes n where n.id between | |
2329800000 and 2347300000 and n.id % 10 =0; | |
-- JOIN | |
explain analyze select n.id, n.changeset_id, u.id, u.display_name from current_nodes | |
n join changesets c on n.changeset_id = c.id join users u on c.user_id = | |
u.id where n.id between 2329800000 and 2347300000 and n.id % 10 =0; -- 15-19ms | |
-- standalone | |
explain analyze select n.id, n.changeset_id from current_nodes n where n.id between | |
2329800000 and 2347300000 and n.id % 10 =0; -- 15ms | |
-- pick some random changesets from this list | |
select distinct n.changeset_id from current_nodes n where n.id between | |
2329800000 and 2347300000 and n.id % 10 =0 LIMIT 20; | |
-- plug them in here in the cache-populating query | |
explain analyze select u.id, u.display_name from changesets c join users u on | |
c.user_id = u.id where c.id = 16425306; -- 0.09ms | |
-- total times are 15-19ms | |
-- or 15+0.09*137=27.33 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment