Skip to content

Enable docs not in index. #2637

Open
Open

Description

@wojons

while working with @nickpoorman. He has millions of documents in a table where each document is less then the 250 byte threshold if data should be stored in the index or not. Because his data is in the index with millions of documents, 8gb ram instances, 4gb default ram cache setting and about 10gb of data at the moment he cant keep his index in memory. So even a count on the table becomes super slow and when he has other read and write workloads running all demanding different parts of the index to be in memory its not a simple scan on the ssd.

A suggestions is when creating a table to disable storing data in the primary index. this is useful for trying to keep index in memeory. and only then hitting disk for the exact records needed.

Activity

  1. srh commented on Jul 2, 2014

    @srh
    Contributor

    We could reduce the threshold to something much smaller before a document is stored in inline. It sounds like the current number, 250, is too big, in light of the existence of indexes.

  2. added this to the subsequent milestone on Jul 2, 2014
  3. modified the milestones: , subsequent on Jul 2, 2014
  4. coffeemug commented on Jul 2, 2014

    @coffeemug
    Contributor

    Moving to polish and assigning to @srh. I think lowering the 250 byte limit seems sensible in light of secondary indexes, and is a better and easier solution than having non-primary indexed docs. Also marking as high priority because the rest of the system got good enough that this matters now.

  5. srh commented on Jul 2, 2014

    @srh
    Contributor

    Note to self: this change to the disk format has backwards compatibility issues. (Note to everybody else: that's ok.)

  6. nickpoorman commented on Jul 2, 2014

    @nickpoorman

    @wojons suggested I try running count with a client instead of Data Explorer because it would error out every time.

    Under zero load... with ~22 million documents, (that look like the following), it takes me on average 5 minutes to get a count.

    Under a load of ~3k writes/sec, count never returned (it's been running for > 30 min now).

    { sample: 'NG_3456', compound: n:23.45:2.3:4.5, createdAt: 1404310585099, abd: 3456.23 }

    Environment:
    Ubuntu 13.10 16gb ram, SSD, 4 core
    node.js --version: v0.11.13
    rethinkdb --version: rethinkdb 1.13.1 (CLANG 5.1 (clang-503.0.40))
    rethinkdbdash driver version: 1.13.6

    Test code:

    var co = require('co');
    var debug = require('debug')('test');
    var re = require('rethinkdbdash')({
      host: '192.168.1.147',
      port: 28015,
      db: 'ml',
    });
    
    co(function * () {
      debug('stating count');
      var start = process.hrtime();
      var c = yield re.table('sample_compounds').count().run();
      var end = process.hrtime(start);
      debug("count: ", c);
      debug("Execution time (hr): %ds %dms", end[0], end[1]/1000000)
    })();
  7. nickpoorman commented on Jul 2, 2014

    @nickpoorman

    Edit:

    "Under a load of ~3k writes/sec, count never returned (it's been running for > 30 min now)."

    It returned after an hour and a half. Coincidentally, count returned at the same time the load on the server also dropped to zero (because I stopped doing inserts).

  8. wojons commented on Jul 2, 2014

    @wojons
    ContributorAuthor

    @srh and @coffeemug i disagree with just playing aound with the default if ur not going to make it configurable for everyone else. For some people the 250 byte size works exactly how they want it and there application may require it now. Also @nickpoorman docs were on average 89 bytes in i remeber meaning you would have to make the default really small to avoid him being in the index. So the better idea is to allow the user to set that threshold per table and if set to 0 it disables the feature all together.

  9. coffeemug commented on Jul 3, 2014

    @coffeemug
    Contributor

    @wojons -- specifying the byte size on table level (where zero means "never write data inline") would be pretty cool, but I don't know if that's doable. It's quite hard to bulletproof the btree splitting and merging code, and I'd be really worried about making this value user configurable.

  10. danielmewes commented on Jul 3, 2014

    @danielmewes
    Member

    I don't think we should just lower the value. At the very least we have to test this very carefully.

    count() is a special case because we don't load the data, but for almost any other operation storing more values inline will make them faster because of improved cache efficiency. Storing almost everything outside the tree will make many operations incredibly inefficient. Just think of doing a table scan over out-of-memory data on rotational drives. We are talking about a slowdown of at least a factor of 10 if documents are suddenly not in the leaf nodes anymore but have to be retrieved from different places all over the disk one at a time (rather than loading a single leaf node with ~10 documents).

    Also in the absence of secondary indexes, storing small documents outside the tree wastes a huge amount of disk and cache space right now, because block sizes are multiples of 512 bytes.

  11. danielmewes commented on Jul 3, 2014

    @danielmewes
    Member

    Also consider the LBA overhead that we have for each out-of-tree document. Right now we can handle pretty big out of memory databases with a lot of documents as long as most of them are small enough to be stored inline. That wouldn't be possible anymore with each document taking its own block id, unless a significant amount of additional RAM is available.

  12. coffeemug commented on Jul 3, 2014

    @coffeemug
    Contributor

    @danielmewes -- perhaps I fell in love with @srh's idea prematurely.

  13. modified the milestones: backlog, on Jul 3, 2014
  14. wojons commented on Jul 3, 2014

    @wojons
    ContributorAuthor

    @danielmewes @coffeemug the reason i think this is configurable is because no matter how much we test for the right value the user will learn more about there data and will be able to pick the number that works best for them.

    @danielmewes whats the issue with having everything outside of the index how does it work with docs when they are larger then what should fit in the index in my application almost non of my data fits within the index. also i would think that the perfomance of getting data that is not in the index depends on the number of records that need to be inspected. if ur able to use ur primary key index and only look at 1% of data to be inspected with lets say a filter then it would be alot faster then having to page all data from disk into memeory to even check the indx first and then they data would be with it .

  15. danielmewes commented on Jul 3, 2014

    @danielmewes
    Member

    @wojons: You're right, for point gets through an index there is no significant difference in performance. It's mostly queries like table().filter() or table().group().map().reduce() that suffer from non-inline data if the data set is too big for main memory and on a rotational drive.

    Generally, I don't think it would be technically difficult to make the threshold configurable. Balancing operations on the tree (merge, level, split) shouldn't be affected by that change. Only if we want the maximum inline size to be higher than 250 bytes, we would have to do major changes in the btree code. Allowing a configuration option to go into out-of-tree storage at smaller values than that should work fine without any significant changes.

    At the same time I'm not a big fan of making this configurable though. It's a very technical parameter which impact is difficult to understand.
    Once we get efficient count(), the main advantage in storing everything outside the main btree will go away. The remaining advantage would be less data duplication with secondary indexes. But as things are now, you would need at least two secondary indexes to see an improvement considering the 512 byte size rounding of out-of-tree storage.

    @srh once mentioned the idea of making multiple blobs share a block, which would avoid the space overhead problem in the absence of many indexes. Though i/o efficiency issues for table scans would still remain.

  16. srh commented on Jul 3, 2014

    @srh
    Contributor

    Instead of blobs sharing a block, I would rather have variable width blocks with on-disk garbage collection packing them together smartly.

  17. wojons commented on Jul 3, 2014

    @wojons
    ContributorAuthor

    @danielmewes i know its a pretty low level setting that most users would not play with but have you seen all the small low level settings in mysql. its one of the reasons people always go back to rdbms from nosql because most nosql systems have no settings of there own and there dev teams always think the defaults they set are the best so they are trying to tune the kenrel which can be a mess if u have more then one workload on that server or complining your own version of there code base which is more work then them expopsing configurable options.

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