The Network People Support Forums

Other TNPI Software => NicTool => Topic started by: slink on January 31, 2007, 11:14:11 PM

Title: performance optimisation / bug in NicToolServer::Zone::get_group_zones
Post by: slink on January 31, 2007, 11:14:11 PM
Hi everyone,

first of all: I considered subscribing to nictool-developers, but I hope that this
is also a place for bug reports / fixes. If not, please tell me what is the best
way and I will take it.

Regarding the actual issue:

With many groups, NC is slower than necessary whenever
NicToolServer::Zone::get_group_zones is called.

I dont have deep insight into NC yet and have only spent 2 hrs on this
issue yet, but as far as I understand, this method basically tries
to get the result count first, before querying the db for the actual
results.

Gettting the count of delegates/pseudo delegates is done in a
massive select count distinct .. left join, which, in our setup,
takes something between 6 seconds and 2 minutes.

Though the select count distinct could be optimised itself, I believe
that it does not make much sense to get the (pseudo) delegates
count first rather than getting the result which, in most cases,
will be queried anyway.

Therefor, I suggest to eleminate the delegates/pseudo delegates
count sql query.

I will attach a diff and my suggested fix. the if(0) block is only for
documentation, and should be removed when committing this
change, as well as my comments.

There is also another issue I stepped over: In the original code,
the search conditions where appended to the count query, but
not to the delegate queries themselves, which I believe can not
be correct. Therefor, I suggest to append the search condition
and clauses to those queries as well.

Nils
Title: Re: performance optimisation / bug in NicToolServer::Zone::get_group_zones
Post by: matt on February 02, 2007, 01:44:02 AM
Hi Nils,

This is a perfectly good place to post this, but I'm moving it to the Developers Corner, as that's where I'll be "refreshing" my memory of things to fix when I get around to making updates for a new NicTool release. That should happen in the next few weeks.

I'll review the code in question and likely add your patches. I need to review that code and understand why it's doing what it is before I change it.

Thanks for the patches!
Matt