Skip to content

Add support for sampled querying based on user-defined time/error constraints #1344

Open

Description

@pixelspark

One way to improve a database's performance is to reduce the volume of data that is being read and processed at all for a particular query. A way of doing this is to allow the user to specify the required statistical boundaries for the results, and use the smallest sample possible for answering the query.

In BlinkDB (which runs atop of Hive, Shark and Spark) it is possible to specify a time (WITHIN 2 SECONDS) or error constraint (ERROR 0.1 CONFIDENCE 95%). When used, BlinkDB will automatically run the query on a sample so that the constraints are met, and will return confidence intervals for aggregations. For more information, see http://blinkdb.org/index.html#Examples.

Although this is a long shot and probably would need a lot of refactoring, it would still be nice if this sort of think would become possible in the future. I guess syntax could be something like r.db('foo').table('transactions').filter({category: "Vegetables"}).groupBy('product', r.avg).bounded({time: 2, confidence: 0.95, error: 0.1})

Activity

  1. neumino commented on Aug 22, 2013

    @neumino
    Member

    We don't have a timeout command, but for the error, confidence, you can use the sample command.
    To get a constraint (like error 0.1, confidence 0.95), you would have to do a count query, compute the good parameter for sample and then run your map/reduce.

    Using it with groupBy is however not possible (or at least I can't think of an efficient way of doing it).

    It's certainly not as friendly as giving an error and a constraint. I leave @coffeemug chime in for an ETA, but that's probably not going to happen before 2.0 even if it's quite a cool feature.

  2. pixelspark commented on Aug 22, 2013

    @pixelspark
    Author

    @neumino I believe BlinkDB does more sophisticated things than just create shortcuts for sampling. In particular, they have implemented automatic generation and caching of relevant samples (which is where their performance comes from).

  3. neumino commented on Aug 22, 2013

    @neumino
    Member

    Yes, their core is about providing estimates, so things are optimized for that. From what I read (I haven't read a lot, so I may be wrong), but they keep some samples in memory that they periodically adjust.
    I am not sure RethinkDB will keep some samples in memory, not that because it's impossible or hard to do, but because I would tend to think of estimates as an edge case.

    Typically, if you are a social network, you cannot compute the number of friends of someone just based on a sample because the data is too skewed.

    Incremental map/reduce (#1118) and triggers (#997) can probably be an efficient solution/workaround to compute estimates.

  4. coffeemug commented on Aug 27, 2013

    @coffeemug
    Contributor

    Moving to backlog, since this won't happen until 2.0. This is a really neat idea (@mglukhovsky and I looked at BlinkDB and though, man, it would be cool if Rethink could do that!) But our primary goal now is to have an amazing database for people building realtime applications, not to have an analytics database (though I do realize the lines can get blurry).

    We'll probably go back to this once we run out of low-hanging fruit.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions