ontehfritz / api.mtgdb.info

Project closing first of August 2015
http://www.mtgdb.info/
MIT License
36 stars 8 forks source link

Random cards on full set performance enhancement. #72

Closed ontehfritz closed 9 years ago

ontehfritz commented 10 years ago

The database uses multiverseId as the card key. Unfortunately there are gaps in multiverse Id, the current random approach on the full card catalog was to generate a random number less or equal to the max multiverse Id, this resulted in reoccurrence of certain cards.

This has been revised to generate the random Id and try to match without the greater than clause. If the card is null then try again until we get a match. This seems to be working well. However, the brute force way of getting a card match potentially could cause some performance concerns. I have ran a few test getting 10000 random cards the average is 20s/10000 cards. Not to bad but can be improved.

To improve another database field needs to be created that has no gaps in the numbering. This way each random number is guaranteed a hit.

ontehfritz commented 10 years ago

Sticking this in futures, not priority and no complaints yet on performance the current way