Skip to content

Instantly share code, notes, and snippets.

@alekseyl
Last active March 13, 2018 13:52
Show Gist options
  • Save alekseyl/c683346db6645f5353dceae4cb54a68c to your computer and use it in GitHub Desktop.
Save alekseyl/c683346db6645f5353dceae4cb54a68c to your computer and use it in GitHub Desktop.
Array sampling perfomance in postgres
+----------------+-----------------+-----------------+-----------------+---------------+---------------+-----------------+----------------+----------------+
| N/cards/M | order by random | random() < 0.xx | generate_series | M partials | ruby way | Unfold | ORM random(rw) | ORM random(mp) |
| 10 / 10 / 5 | 0.32ms / 4.27 | 0.26ms / 3.55 | 0.25ms / 3.44 | 0.31ms / 4.13 | 0.28ms / 3.82 | 0.07ms / 1.0 | 0.17ms / 2.3 | 0.19ms / 2.55 |
| 100 / 10 / 5 | 0.66ms / 9.69 | 0.47ms / 6.9 | 0.26ms / 3.85 | 0.29ms / 4.22 | 0.31ms / 4.59 | 0.07ms / 1.0 | 0.2ms / 3.01 | 0.19ms / 2.74 |
| 1000 / 10 / 5 | 4.39ms / 10.09 | 2.98ms / 6.86 | 0.51ms / 1.16 | 0.57ms / 1.32 | 0.66ms / 1.51 | 2.89ms / 6.63 | 0.55ms / 1.26 | 0.44ms / 1.0 |
| 10000 / 10 / 5 | 43.06ms / 22.11 | 26.48ms / 13.6 | 1.79ms / 0.92 | 2.17ms / 1.11 | 3.18ms / 1.63 | 22.89ms / 11.75 | 3.01ms / 1.55 | 1.95ms / 1.0 |
+----------------+-----------------+-----------------+-----------------+---------------+---------------+-----------------+----------------+----------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment