Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JakSprats/774345 to your computer and use it in GitHub Desktop.
Save JakSprats/774345 to your computer and use it in GitHub Desktop.
bash script
- 1 requires no sorting and is 25% faster than 2
(sorting requires adding each row to a list, then copying the list to a vector of pointers, and then qsorting the vector)
- 2,3,4 are basically equivalent
Conclusion:
multiple column sorting has almost no overhead, but sorting has a 25% hit (for this use-case)
BENCH=./gen-benchmark
1.) use PK (no sorting)
taskset -c 1 $BENCH -q -c $C -n $REQ -s -A MULTI -Q SELECT \* FROM obycol WHERE "id BETWEEN 1 AND 10 ORDER BY id LIMIT 4 OFFSET 3"
38207.73 requests per second
2.) use unindexed column (sort) and sort to one column
taskset -c 1 $BENCH -q -c $C -n $REQ -s -A MULTI -Q SELECT \* FROM obycol WHERE "id BETWEEN 1 AND 10 ORDER BY m LIMIT 4 OFFSET 3"
28815.95 requests per second
3.) use unindexed column (sort) and sort to two columns
taskset -c 1 $BENCH -q -c $C -n $REQ -s -A MULTI -Q SELECT \* FROM obycol WHERE "id BETWEEN 1 AND 10 ORDER BY j,m LIMIT 4 OFFSET 3"
28535.61 requests per second
4.) use unindexed column (sort) and sort to three columns
taskset -c 1 $BENCH -q -c $C -n $REQ -s -A MULTI -Q SELECT \* FROM obycol WHERE "id BETWEEN 1 AND 10 ORDER BY i,j,m DESC LIMIT 4 OFFSET 3"
27923.74 requests per second
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment