Comments (5)
Your code looks correct and no, there shouldn't be any duplicates :)
from randumb.
Thanks!
On Sun, Dec 4, 2011 at 9:26 AM, spilliton <
[email protected]
wrote:
Your code looks correct and no, there shouldn't be any duplicates :)
Reply to this email directly or view it on GitHub:
#3 (comment)
from randumb.
Thank you, is it faster than questions_of_quota.sort_by{rand}[1..10] ?
from randumb.
In instances where your data set is very very small, retrieving all of your data (like in your example), and then doing sort_by, I believe will be faster because my gem does 2 DB queries instead of 1. However, if you have a very large data set, and questions_of_quota.all returns 100 or so records, then my gem is much faster because it doesn't have to serialize 100 objects only to throw away 90 of them that you aren't going to use :)
It does this by doing one query to only obtain the ID's of the matching records, then randomly choosing the from that set of IDs, then fetching the records using those ID's
from randumb.
thanks for explanation
from randumb.
Related Issues (17)
- SQLite 3 - Statement Invalid - Missing Asterisk HOT 9
- select_all loads all IDs in memory HOT 3
- Random but unique/distinct? HOT 1
- order by error. HOT 11
- Performance HOT 3
- undefined method 'uniq_value' HOT 7
- License HOT 2
- Not working on Rails 3.2.8? HOT 5
- Randumb doesn't work in Rails 4 HOT 1
- [feature] add seed parameter HOT 6
- It is possible that this returns an activerecord_relation instead of a an array? HOT 4
- Add change log entry for 0.5.0 HOT 4
- wheight by created_at HOT 6
- Does not respect default scopes HOT 1
- NoMethodError - undefined method `reverse_merge' for 30:Fixnum HOT 4
- undefined method `shuffle!' HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from randumb.