Page 1 of 1
Is a number of sql queires important?
Posted: Mon May 26, 2008 7:28 am
by vilkis
Hi,
I think that the number of sql queries should be reduced to such a value as it is possible. However, it is not a case in some modules. For example in FormBuilder, several sql queries are used to generate each field of form - this leads to about 50 queries for a form of 20 fields. It is to much in my opinion. In cmsms forum I can't see anybody who cares about this issue. Maybe a large number of queries is not issue?
Let discuss on this topic.
Vilkis
Re: Is a number of sql queires important?
Posted: Mon May 26, 2008 6:27 pm
by Pierre M.
Hello,
vilkis wrote:
...In cmsms forum I can't see anybody who cares about this issue....
Yes, lots of people care about a too high number of SQL queries per rendered page. Please research for "sql", "queries" with google and its "site" parameter. There are discussions and hints.
Pierre M.
Re: Is a number of sql queires important?
Posted: Mon May 26, 2008 7:24 pm
by duclet
It is really up to the module developer to code in the most efficient manner. Certainly they can use less SQL queries but that all depends on them. You could always edit the module to reduce the number of queries if you want. In my modules, I do try to cache the results of my queries and methods that requires a lot of calculations but again, it is up to the individual developer.
Re: Is a number of sql queires important?
Posted: Mon May 26, 2008 7:51 pm
by calguy1000
Also consider that caching of query results usually only happens on a 'per request' basis, and is really only useful if that queried data is going to be re-used in the same request. Also, caching the query results may result in a significantly increased memory requirement for that request, and thereby limiting its use on certain hosts, and/or effecting performance. Therefore it may be better in some circumstances to try to rely on the mysql query cache.
Some developers may have already had these thoughts and decided to rely on SQL queries rather than caching data given the dynamics of the particular module, etc. Also dependiig on the module, it may be extremely difficult to provide functionality AND keep the number of queries down. Usually developers consider these factors.
That said... I know that I could optimize some things in my modules... particularly FEU, I just haven't gotten there yet. I also know that there are some more things in the core that I personally would like to see cached, but people are already having problems with the memory requirements.
It's a general problem of tradeoffs between developer skill, developer time, performance, memory requirements, functionality, and use-ability. And is best attacked IMHO on a per module/per query basis.
Just saying 'too many sql queries' doesn't mean anything.
Re: Is a number of sql queires important?
Posted: Fri May 30, 2008 11:20 am
by vilkis
If somebody edits module, then after update of original module the modifications should be performed... It is not very convenient.
It seems (in calgay1000 opinion) that there is no only one rule: to reduce number of queries as it is possible. Does it mean that I do not need care about number of queries? Then I do not understand why in FormBrowser help there is such a sentence
"Known Issues
* FormBrowser is tremendously inefficient with regards to database queries. The performance may well suck, especially if you have more than three records."
I just want to clear up these sql related questions before joining CMSMS developer team.
Re: Is a number of sql queires important?
Posted: Fri May 30, 2008 12:24 pm
by duclet
You should code the way you normally code. Obviously, there is not a single method that is perfect or else everyone would be using it. Each module is different and should be coded to best its performance. What I usually do is first get a working module up and running. Afterwards, go back and improve the code.