Re: RES: [PHP] Mutiple SQL request
| From: | Jim Lucas | Date: | Wed, 04 Feb 2009 16:38:14 +0000 |
| Subject: | Re: RES: [PHP] Mutiple SQL request | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287615@lists.php.net to get a copy of this message | ||
Jônatas Zechim wrote:
> For example i’ve this query:
>
>
>
> SELECT admin_nome FROM ctalk_admin WHERE admin_lastping <= '1233762658' AND
> admin_lastping >= '1233762608' AND admin_id='1'
>
>
>
> I ran explain, the result for extra is ‘Impossible WHERE noticed after
> reading const table...’
>
> How can i optimize this query?
>
> Is there some tutorial on the net?
>
I am going to guess that that admin_id column is already your primary key and therefor is unique and
indexed by default.
I would add a compound index to ctalk_admin
ALTER TABLE
ctalk_admin ADD INDEX (admin_id, admin_lastping)
or something along that line.
>
>
> Thanks,
>
> Zechim
>
>
>
> De: Bastien Koert [mailto:phpster@gmail.com]
> Enviada em: quarta-feira, 4 de fevereiro de 2009 12:46
> Para: Jônatas Zechim
> Cc: php-general@lists.php.net
> Assunto: Re: [PHP] Mutiple SQL request
>
>
>
>
>
> On Wed, Feb 4, 2009 at 9:43 AM, Jônatas Zechim <zechim.php@gmail.com> wrote:
>
> Hi there, i've a system that do a query each 3s, does it impact on mysql
> Server?
> I mean, can this slow my Server?
>
> zechim
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> It impacts system recources if this same query is run constantly for each
> user. Example: if this runs a logon and you have 100 or 1000 users logging
> on at roughly the same time, then you will have contention for the
> resources.
>
> Can you check your indeces and run explain plans on the queries to see if
> any of them can be optimised to run quicker?
>
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare