Is a number of sql queires important?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
vilkis

Is a number of sql queires important?

Post 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
Pierre M.

Re: Is a number of sql queires important?

Post 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.
User avatar
duclet
Forum Members
Forum Members
Posts: 187
Joined: Fri Jun 23, 2006 12:55 pm

Re: Is a number of sql queires important?

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Is a number of sql queires important?

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
vilkis

Re: Is a number of sql queires important?

Post 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.
User avatar
duclet
Forum Members
Forum Members
Posts: 187
Joined: Fri Jun 23, 2006 12:55 pm

Re: Is a number of sql queires important?

Post 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.
Post Reply

Return to “Developers Discussion”