Gnul wrote:
The LIMIT expression is applied after the results have been gathered.
I refer to: http://dev.mysql.com/doc/refman/5.0/en/limit-optimization.html Quote: As soon as MySQL has sent the required number of rows to the client, it aborts the query unless you are using SQL_CALC_FOUND_ROWS.
So it's faster with the limit 1 or limit 0,1 as it's stops the query once it'f found a result. Especially in large tables this can be significant. I doubt the speed will be significantly improved in this application, but It's good practice. I've worked on DBs of +5 TerraBytes and there the the Increase in speed was significant.
-----Original Message----- From: dev-bounces+dirk.rennen=kpn.be@lists.roundcube.net [mailto:dev-bounces+dirk.rennen=kpn.be@lists.roundcube.net] On Behalf Of gnul Sent: donderdag 8 januari 2009 20:20 To: dev@lists.roundcube.net Subject: Re: [RCD] File naming conventions
I'm not a developer of this project, so I cannot speak for it, but these are some thoughts:
Dirk Rennen wrote:
You should also consider putting html comment tags around the javascript code (<!-code //) so it wont output if javascript is turned off.
To make sure javascript is turned on, you should consider disabling all process buttons and turning them on at runtime.
Personally, I wouldn't worry about javascript checking until a 1.0 release. (And if you are forcing javascript, you should redirect to an error page post-login.) All modern browsers support parsing <script> tags even if javascript is off. The proper way to separate inline javascript from the html is as follows:
<script type="text/javascript"> //<![CDATA[ .. javascript code here ... //]]> </script>
I haven't looked at the database conventions, but what I personally always do is the following:
SELECT field FROM Table WHERE otherfield LIKE 'value' LIMIT 0,1;
As you can see sql-specific parts are in uppercase, fields in lowercase and table in ucfirst. This way you can separate what they are by simply looking how it's written.
I totally agree on uppercasing SQL keywords as most IDEs won't syntax-highlight inside strings.
PS the LIMIT 0,1 (mysql) is a faster query then without, even when you know there can only be one value returned, as it stops looking after it's found one which it wont if the limit is not there.
I disagree here -- I could be wrong, but please prove me wrong. If you *know* the query will only return one row (because your WHERE statement uses a primary key and there are no left-joins or other mechanisms to provide multiple rows) then the limit will not help. The LIMIT expression is applied after the results have been gathered. (Use 'explain' before your query to test this.)
I agree the LIMIT *is* faster when multiple rows *may* be returned. But if you only want one row out of a possible set, then the query will already have the limit statement.
Thus, adding LIMIT 1 or LIMIT 0,1 to all single-row queries is redundant.
-gnul _______________________________________________ List info: http://lists.roundcube.net/dev/ _______________________________________________ List info: http://lists.roundcube.net/dev/