<div>Now I&#39;m getting a performance problem.</div><div><br></div><div>I&#39;m bulk loading transactions in sets (from a file) of 1250. Each of one has references to 3 objects, 3 numbers and 2 dates.</div><div><br></div>
<div>When I test it without setting the customer it take to me 614 milliseconds to create the 1250 instances but if I look up for each client according to the client code it take to me 204158 milliseconds (3.40 minutes). </div>
<div>Customers is a MagmaCollection and this is the method of the message that I&#39;m sending 1250 times:</div><div><br></div><div><div>customerAtDocumentNumber: unString sex: otroString</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&quot;Devuelve un invividuo o una organizacion dependiendo de si unString corresponde a un número de documento o a un número de cuit. NOTA: se debe tener en cuenta el sexo por existir números de dni repetidos entre varones y mujeres.&quot;</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>| aFewCustomers |</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>aFewCustomers := self customers where: [ :each | (each documentNumber = unString)].</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>^customers detect: [:each | each documentNumber = unString and: [each sex = otroString]] ifNone: []</div><div><br></div><div><br></div><div><br></div><div>
Customers has an index on documentNumber. Now I go to profile it but I need to find how to do it in Pharo. </div><div>I thing that I can switch customers from MagmaCollection to MagmaDictionary and set the document number + sex how the key. What do you think?</div>
<div><br></div><div>See you,</div><div>Facu</div><div><br></div><br><div class="gmail_quote">On Thu, Dec 9, 2010 at 7:36 PM, Facundo Vozzi <span dir="ltr">&lt;<a href="mailto:facundov79@gmail.com">facundov79@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><br>
<br>
</div>If you do a copy, then you will be creating multiple instances of<br>
various &quot;system entities&quot;, which I&#39;m guessing don&#39;t want to do; you<br>
would rather have just one instance, referenced from multiple<br>
transactions, right?<br></blockquote><div><br></div></div><div>Yes, you&#39;re right I don&#39;t want multiple instances. </div><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<br>
So all you need to do is just look-up the *equivalent* Code in session<br>
which is doing the loading.  It will be the one identical instance in<br>
the repository.<br></blockquote><div><br></div></div><div><div>Yes, to do that I&#39;m passing the session which is doing the loading by </div><div>argument.  But I think that my error here is that I&#39;m implementing the protocol to get one entitiy instance by code or name on the Entity class side. I think is </div>

<div>better implement it, by example #clientOfCode: aCode, in my system instance</div><div>which is the root of each session. In this manner I don&#39;t need pass the user session by argument. I think that my traditional database mapping thinking betrayed me</div>

</div><div class="im"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
But yes, this is one of the use-cases for which FP&#39;s were invented, it<br>
can be a more elegant solution, especially if the number of Codes is<br>
always changing or increasing.  See<br>
MagmaTestCase&gt;&gt;#testForwardingProxy.<br></blockquote><div><br></div></div><div>Yes, I will see it right now.</div><div><br></div><div>Facu</div><div><div></div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<font color="#888888"><br>
 - Chris<br>
</font><div><div></div><div><br>
<br>
&gt; Thanks for your help,<br>
&gt; Facu<br>
&gt;<br>
&gt; On Thu, Dec 9, 2010 at 4:35 PM, Chris Muller &lt;<a href="mailto:asqueaker@gmail.com" target="_blank">asqueaker@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m not sure I fully understand the context, but a third option might<br>
&gt;&gt; be to use ForwardingProxies.  Especially if the shared objects can be<br>
&gt;&gt; updated by only one session (like a batch updater, for example).  Then<br>
&gt;&gt; every other (user client) session will share the same instances in<br>
&gt;&gt; memory.<br>
&gt;&gt;<br>
&gt;&gt; HTH,<br>
&gt;&gt;  Chris<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Dec 8, 2010 at 1:13 PM, Facundo Vozzi &lt;<a href="mailto:facundov79@gmail.com" target="_blank">facundov79@gmail.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt; &gt; Hi all,<br>
&gt;&gt; &gt; I&#39;m refactoring my code and I found that I have two ways to do the same<br>
&gt;&gt; &gt; in<br>
&gt;&gt; &gt; distint parts of my system.<br>
&gt;&gt; &gt; 1) Entity class &gt;&gt; atCode: aCode<br>
&gt;&gt; &gt; &quot;Answer the receiver instance with code equal to aCode or evaluate<br>
&gt;&gt; &gt; aBlock if<br>
&gt;&gt; &gt; it doesn&#39;t exists.&quot;<br>
&gt;&gt; &gt;        ^(self all detect: [:one | one code = aCode]) copy<br>
&gt;&gt; &gt; or<br>
&gt;&gt; &gt; 2) Entity class&gt;&gt; atCode: aCode inSession: anUserSession<br>
&gt;&gt; &gt; &quot;Answer the receiver instance with code equal to aCode or evaluate<br>
&gt;&gt; &gt; aBlock if<br>
&gt;&gt; &gt; it doesn&#39;t exists.&quot;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;        ^(self allInSession: anUserSession) detect: [:one | one code =<br>
&gt;&gt; &gt; aCode]<br>
&gt;&gt; &gt; The difference is that 1 is using the shared session so I need copy the<br>
&gt;&gt; &gt; object to be used (referenced by other object) on anUserSession. The<br>
&gt;&gt; &gt; uggly<br>
&gt;&gt; &gt; of 2 is that I have to pass anUserSession as argument.<br>
&gt;&gt; &gt; Either way works well, is really the same?<br>
&gt;&gt; &gt; Thanks in advance,<br>
&gt;&gt; &gt; Facu<br>
&gt;&gt; &gt; (*) I eliminate aBlock for absent elements for this example<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; Magma mailing list<br>
&gt;&gt; &gt; <a href="mailto:Magma@lists.squeakfoundation.org" target="_blank">Magma@lists.squeakfoundation.org</a><br>
&gt;&gt; &gt; <a href="http://lists.squeakfoundation.org/mailman/listinfo/magma" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/magma</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div></div></div><br>
</blockquote></div><br></div>