Git Product home page Git Product logo

Comments (5)

spilliton avatar spilliton commented on June 18, 2024

Your code looks correct and no, there shouldn't be any duplicates :)

from randumb.

hopewise avatar hopewise commented on June 18, 2024

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.

hopewise avatar hopewise commented on June 18, 2024

Thank you, is it faster than questions_of_quota.sort_by{rand}[1..10] ?

from randumb.

spilliton avatar spilliton commented on June 18, 2024

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.

hopewise avatar hopewise commented on June 18, 2024

thanks for explanation

from randumb.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.