Skip to content

Instantly share code, notes, and snippets.

@rponte
Last active March 18, 2025 14:44
Show Gist options
  • Save rponte/dadd7785b00690069bd0f673ddd18fef to your computer and use it in GitHub Desktop.
Save rponte/dadd7785b00690069bd0f673ddd18fef to your computer and use it in GitHub Desktop.
Patitioning: the third pillar of scalability

Interesting articles and content about data partitioning

Slotted Counter Pattern

Some articles and tips about Slotted Counter Pattern:

Shuffling and randomizing rows with SQL

Data partitioning

Database sharding

@rponte
Copy link
Author

rponte commented Sep 2, 2024

Example of using the MOD() function to partition the result set:

    SELECT t.*
      FROM tasks t
     WHERE t.status = 'PENDING'
       AND mod(t.id, :total_machines) = :machine_key   -- that's how we partition the tasks among the machines
  ORDER BY t.created_at
     LIMIT 50

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment