Disable change tracking?

758 views
Skip to first unread message

Brian Vallelunga

unread,
Aug 22, 2012, 11:58:12 AM8/22/12
to rav...@googlegroups.com
I've seen references to this feature, but I cannot find out how to disable change tracking for a given query. I need to export a large amount of data (looping through paged results) and figured it would reduce a lot of memory if the session wasn't tracking everything.

Thanks

Oren Eini (Ayende Rahien)

unread,
Aug 22, 2012, 12:06:22 PM8/22/12
to rav...@googlegroups.com
session.Advanced.Evict

Brian Vallelunga

unread,
Aug 22, 2012, 12:40:07 PM8/22/12
to rav...@googlegroups.com
I've known about Evict, but is there no way to disable the tracking before making the query then, correct? This seems like it would be under Customize, but I haven't found anything.

Chris Marisic

unread,
Aug 22, 2012, 12:43:49 PM8/22/12
to rav...@googlegroups.com
You can work with session.Advanced.StartsWith to get raw json docs, and then call  https://groups.google.com/d/msg/ravendb/U4UDZf6HWus/ldCWUNbEnj4J

But it seems like there should be a way to disable tracking for a session.

Oren Eini (Ayende Rahien)

unread,
Aug 22, 2012, 1:21:38 PM8/22/12
to rav...@googlegroups.com
There is no cost of change tracking during the query

Chris Marisic

unread,
Aug 22, 2012, 2:22:05 PM8/22/12
to rav...@googlegroups.com
I find that hard to accept, how can it have NO cost?

How do you do change tracking without initializing dynamic proxies?

Oren Eini (Ayende Rahien)

unread,
Aug 22, 2012, 2:23:37 PM8/22/12
to rav...@googlegroups.com
Simple, I don't do dynamic proxies.
The only thing that we do for change tracking is keep track of the entities (a dictionary inside the session).
The only cost is when you call SaveChanges(), when we actually need to check for changes.

Chris Marisic

unread,
Aug 22, 2012, 2:30:43 PM8/22/12
to rav...@googlegroups.com
Even with that, don't you have to clone the entities?

Oren Eini (Ayende Rahien)

unread,
Aug 22, 2012, 6:47:06 PM8/22/12
to rav...@googlegroups.com
No, we keep the originally load value in the session, is all.

Chris Marisic

unread,
Sep 20, 2012, 11:42:35 AM9/20/12
to rav...@googlegroups.com
Can you elaborate on how this check for changes work?

Is this information exposed in any meaningful way?

Oren Eini (Ayende Rahien)

unread,
Sep 20, 2012, 11:49:56 AM9/20/12
to rav...@googlegroups.com
Define meaningful. :-)
You can check if an entity has changed, or if all of them changed.

The relevant behavior is at: InMemoryDocumentSessionOperations

entitiesAndMetadata
entitiesByKey
deletedEntities

Are where we keep the state

Chris Marisic

unread,
Sep 20, 2012, 12:08:03 PM9/20/12
to rav...@googlegroups.com
Well being able to determine if an object is modified is clearly the least that has to occur to be meaningful, does it provide anything more granular than true/false it's changes, like properties that are different etc?

Oren Eini (Ayende Rahien)

unread,
Sep 20, 2012, 12:08:24 PM9/20/12
to rav...@googlegroups.com
No, it doesn't.

Oren Eini (Ayende Rahien)

unread,
Sep 20, 2012, 12:08:35 PM9/20/12
to rav...@googlegroups.com
What do you want to do with that?

jalchr

unread,
Dec 24, 2012, 2:48:29 AM12/24/12
to rav...@googlegroups.com
There is one very important cost: Memory

Assuming you are loading 1024 docs with paging, multiply that by few hundred page views ... and bang you got 1 GB for extra memory for nothing.

I had to use tricks like:
                DocumentSession.Advanced.DocumentStore.DisableAggressiveCaching();
                DocumentSession.Advanced.DocumentStore.Conventions.ShouldCacheRequest = url => false;            

               // Execute the query

              // for  each loaded doc
              DocumentSession.Advanced.Evict(doc);

to save that amount of client memory.
It would be far more concern focused if I could have written something like:

query.Customize(x => x.NoTracking && x.NoCaching)


where NoTracking disable entity tracking for queried entities.
and NoCaching would disable request caching for them as well.

Those will be very memory-friendly for reporting needs as well.

Fitzchak Yitzchaki

unread,
Dec 24, 2012, 3:54:14 AM12/24/12
to <ravendb@googlegroups.com>
Yes, this can be useful. Please open an issue about this.
Anyone wants to make a pull request for this?

jalchr

unread,
Dec 24, 2012, 9:39:03 AM12/24/12
to rav...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages