As far as I'm aware (core team feel free to correct me!) the getProperty() method does a db lookup for each property.
This means that for each member you are doing 12 or so db queries.
Not sure if there is a way round this. However if your first query is taking 2-3 seconds than subsequent queries are very quick it sounds to me like the DB might be spooling up on the first query then is available and quick for the next queries.
If you are using SQL2005 ensure your DB has AutoClose set to false. (It's in the options for the DB)
That's certainly an interesting approach, although it could get unwieldy in itself if there are lots of members with lots of properties as you'd be shunting big lumps of data about.
Perhaps it would better to write a Lucene indexer which indexed members and properties in the DB??
Tim is correct, getProperty does a DB look up each time that you call it. Without some big API design changes this can't be fixed (and isn't on the cards for 4.1).
I'm not sure that a lucene index would be a good idea though, it's that a little big insecure, storing the personal details like that? But you may be able to achieve it with Umbraco Examine, I'll check with Shannon.
.GetProperty on a member object slow
Hi there
I have the following code:
public IntranetMember(umbraco.cms.businesslogic.member.Member member)
{
Firstname = member.getProperty("firstName").Value.ToString();
Lastname = member.getProperty("lastName").Value.ToString();
remove 10 more 'get property' lines.
When i debug the code, the first member.getProperty is very slow, takes about 3-5 seconds to run, after that the rest goes very fast.
I call this constructor once for each member object i got from umbraco, it is only for the first object it takes a long time.
Does anyone have a clue about why this is the case ?
The code is used to search employees in my company, and it is pretty annoying that a simple search takes 5 seconds, there is only 150 objects.
Best regards
Søren Reinke
Hi,
As far as I'm aware (core team feel free to correct me!) the getProperty() method does a db lookup for each property.
This means that for each member you are doing 12 or so db queries.
Not sure if there is a way round this. However if your first query is taking 2-3 seconds than subsequent queries are very quick it sounds to me like the DB might be spooling up on the first query then is available and quick for the next queries.
If you are using SQL2005 ensure your DB has AutoClose set to false. (It's in the options for the DB)
T
There is an interesting approach using XML you could use http://our.umbraco.org/forum/developers/xslt/1812-getting-members-groups-from-member-id-in-xslt
Any access to the database can be particularly slow, I'd recommend adding some caching to the sample in the link and using that.
Hi Chris,
That's certainly an interesting approach, although it could get unwieldy in itself if there are lots of members with lots of properties as you'd be shunting big lumps of data about.
Perhaps it would better to write a Lucene indexer which indexed members and properties in the DB??
Not sure if this has ever been done.
T
A lucene index would be a great idea. I don't think anything like this exists at the moment.
I'll add it to my list of things to do ;-)
Tim is correct, getProperty does a DB look up each time that you call it. Without some big API design changes this can't be fixed (and isn't on the cards for 4.1).
I'm not sure that a lucene index would be a good idea though, it's that a little big insecure, storing the personal details like that? But you may be able to achieve it with Umbraco Examine, I'll check with Shannon.
Hi there
Thanks a lot for the answers.
The solution I have used, is a simple caching of the 150 members including their properties.
is working on a reply...