Re: RES: [PHP] Mutiple SQL request
| From: | Ashley Sheridan | Date: | Wed, 04 Feb 2009 22:04:26 +0000 |
| Subject: | Re: RES: [PHP] Mutiple SQL request | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287651@lists.php.net to get a copy of this message | ||
On Thu, 2009-02-05 at 08:48 +1100, Chris wrote:
> Ashley Sheridan wrote:
> > On Thu, 2009-02-05 at 08:38 +1100, Chris wrote:
> >> 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...’
> >> Well this one is impossible.
> >>
> >> Find records with ping before '1233762658' AND
> >> find records with ping after '1233762608'
> >>
> >> The before time is before the after time.
> >>
> >> --
> >> Postgresql & php tutorials
> >> http://www.designmagick.com/
> >>
> >>
> > Erm, I don't think so, notice that 5 as the second to last digit. He
> > wants to find a ping before the larger number and after the smaller
> > number, which is perfectly valid in the normal rules of the universe I
> > know ;)
>
> *bangs head on desk*
> Going to be a long day...
>
> Either way, mysql knew this query couldn't return any results for some
> reason (hence "impossible where noticed"), so using this as an example
> when trying to optimize will fail.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
MySQL may have noticed it was impossible with the current data he had
using the index on that field, but in the future it may become valid, so
I wouldn't necessary eliminate it if it's deemed crucial. A query that
returns no results is equally as useful as one that returns many.
Ash
www.ashleysheridan.co.uk