Really enjoyed the read. Thanks for sharing. I’m surprised by the random page implementation.
Usually in a database each record has an integer primary key. The keys would be assigned sequentially as pages are created. Then the “random page” function could select a random integer between zero and the largest page index. If that index isn’t used (because the page was deleted), you could either try again with a new random number or then march up to the next non empty index.
For choosing an article, it would be better to just pick a new random number.
Although there are probably more efficient ways to pick a random record out of a database. For example, by periodically reindexing, or by sorting extant records by random (if supported by the database).
7 Comments
over_clox@lemmy.world · 70 pts · 2y
Oddly enough, by posting this data publicly, those least viewed articles will end up getting a lot more views now.
QuinceDaPence@kbin.social · 15 pts · 2y
No Fair
bool@lemm.ee · 26 pts · 2y
Really enjoyed the read. Thanks for sharing. I’m surprised by the random page implementation.
Usually in a database each record has an integer primary key. The keys would be assigned sequentially as pages are created. Then the “random page” function could select a random integer between zero and the largest page index. If that index isn’t used (because the page was deleted), you could either try again with a new random number or then march up to the next non empty index.
AbouBenAdhem@lemmy.world · 28 pts · 2y
Marching up to the next non-empty key would skew the distribution—pages preceded by more empty keys would show up more often under “random”.
SheeEttin@lemmy.world · 19 pts · 2y
Fun fact, that concept is used in computer security exploits: https://en.wikipedia.org/wiki/NOP_slide
For choosing an article, it would be better to just pick a new random number.
Although there are probably more efficient ways to pick a random record out of a database. For example, by periodically reindexing, or by sorting extant records by random (if supported by the database).
bl4kers@lemmy.ml · 9 pts · 2y
Did you know one of the most translated articles on Wikipedia is none other than American actor Corbin Bleu?
https://www.insider.com/why-corbin-bleu-wikipedia-pages-2019-1
DirkMcCallahan@lemmy.world · 5 pts · 2y
Very cool! I love stuff like this.