exchangewebservices - Exchange Webservices Managed API - using ItemView.Offset for FindItems() hits performance of LoadPropertiesForItems method -
i'm doing little research on possible application of ews in our existing project written heavy use of mapi , found out disturbing performance of loadpropertiesforitems() method.
consider such scenario:
- we have 10000 (ten thousands) messages in inbox folder
- we want approximately 30 properties of every message see if satisfy our conditions further processing
- messages retrieved server in packs of 100 messages
so, code looks this:
itemview itemsview = new itemview(100); propertyset properties = new propertyset(); properties.add(emailmessageschema.from); /* add necessary properties... */ properties.add(emailmessageschema.sensitivity); finditemsresults<item> findresults; list<emailmessage> list = new list<emailmessage>(); { findresults = folder.finditems(itemsview); _service.loadpropertiesforitems(findresults, properties); foreach (item in findresults) { ... every items } if (findresults.nextpageoffset.hasvalue) { itemsview.offset = findresults.nextpageoffset.value; } }while(findresults.moreavailable); and problem every increment of itemsview.offset property makes loadpropertiesforitems method longer execute. first couple of iterations not noticeable around 30th time loop makes call time increases under 1 second 8 or more seconds. , memory allocation hits physical limits causing out of memory exception.
i'm pretty sure problems "offset related" because changed code little that:
itemsview = new itemview(100, offset, offsetbasepoint.beginning); ...rest of loop if (findresults.nextpageoffset.hasvalue) { offset = findresults.nextpageoffset.value; } and manipulated offset variable (declared outside of loop) in way set value on 4500 @ start , in debug mode after first iteration changed value 100. , according suspicions first call of loadpropertiesforitems took veeeery long execute , second call (with offset = 100) quick.
can confirm , maybe propose solution that?
of course can work without using offset why should i? :)
changing offset expensive because server has iterate through items beginning -- isn't possible have ordinal index messages because new messages can inserted view in order (think of view on name or subject).
paging through items once best approach.
Comments
Post a Comment