Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Phil Crowe 192 posts 256 karma points
    Dec 16, 2010 @ 12:57
    Phil Crowe
    0

    page taking decades to load

    This is more of a general .net question but as its regarding a method that uses umbraco api someone on here can relate to what im doing.


    1.       foreach (Member m in Member.GetAll)
    {

    Response.Write(m.LoginName);
    }

     2.      foreach (Member m in Member.GetAll)
      {
    if (m.getProperty("screenName").Value.ToString().ToLower() == searchItem.ToLower())
    {
    Response.Write(m.LoginName);
    }
    }

    method one executes in less than a second. when i add the extra 'if' condition, as shown in method 2, the page takes forever to load. i do have 2,500 members, so a lot to get through. but doesnt seem right that the page should take so much longer just for this extra condition. any ideas?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Dec 16, 2010 @ 13:07
    Ismail Mayat
    1

    Phil,

    Member.Getall when getting properties makes quite a few sql calls, do a dig on forum i do recall some optimised sql as an alternative to Member.Getall also if you are using umbraco 4.5.2 then you could use Examine and index the members that will be lightening quick cant remember if all the properties will be in the index will have to double check.

    Regards

    Ismail

  • Phil Crowe 192 posts 256 karma points
    Dec 17, 2010 @ 12:00
    Phil Crowe
    1

    hi ismail, 

    i found the members matching my search terms with in sql with : "select nodeId, datanvarchar, u.[text] from cmsPropertyData pd inner JOIN cmsContent c ON pd.contentNodeId= c.nodeId join umbracoNode u on u.id = c.nodeId WHERE (propertytypeid = <ID OF THE FIRST MATCHING PROPERTY> or propertytypeid = <ID OF THE SECOND MATCHING PROPERTY>) and datanvarchar like '%" + tbFindThisCollection.Text + "%'" plonked this into a datatable and directly accessed each member in this table by their member id.

     

     

     

    foreach (DataRow row in table.Rows)
    {

                    addMember = new Member(Convert.ToInt32(row[0]));
    memberList.Add(addMember);
    index++;

     }

     

    worked a charm :)

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Dec 17, 2010 @ 12:27
    Hendy Racher
    0

    Hi Phil,

    A late reply now you have it working :) but how about a simple XPath query to return all the members you're interested in?

    using uComponents.Core;

    List<Member> members = uQuery.GetMembersByXPath("//node[property = 'value']");

    The above hits the DB once so should also be fast.

     

    The XML fragment for a member is:

    <node loginName="" email="" ...>
    <property>value</property>
    </node>

    Cheers,

    Hendy

Please Sign in or register to post replies

Write your reply to:

Draft