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?
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.
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++;
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?
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
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 :)
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?
The above hits the DB once so should also be fast.
The XML fragment for a member is:
Cheers,
Hendy
is working on a reply...