PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Order of WHERE Clausels
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Order of WHERE Clausels

Réponse
 
LinkBack Outils de la discussion
Vieux 08/11/2007, 10h01   #1
useitall@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Order of WHERE Clausels

Hi all!

would be a query faster, if I put first day option and then all other
like this

SELECT column FROM bigtable WHERE (date > 2007-01-01 AND date <
2007-01-03) AND (somecolumn AND '%searcht%') AND (category LIKE
'%categoryname%')

or it the same

SELECT column FROM bigtable WHERE (somecolumn AND '%searcht%') AND
(category LIKE '%categoryname%') AND (date > 2007-01-01 AND date <
2007-01-03)

I mean, the table could be very big, so first day option would be
minimize slow LIKE's overhead ?

Best regards, Michael

  Réponse avec citation
Vieux 08/11/2007, 10h54   #2
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Order of WHERE Clausels

On 8 Nov, 10:01, useit...@gmail.com wrote:
> Hi all!
>
> would be a query faster, if I put first day option and then all other
> like this
>
> SELECT column FROM bigtable WHERE (date > 2007-01-01 AND date <
> 2007-01-03) AND (somecolumn AND '%searcht%') AND (category LIKE
> '%categoryname%')
>
> or it the same
>
> SELECT column FROM bigtable WHERE (somecolumn AND '%searcht%') AND
> (category LIKE '%categoryname%') AND (date > 2007-01-01 AND date <
> 2007-01-03)
>
> I mean, the table could be very big, so first day option would be
> minimize slow LIKE's overhead ?
>
> Best regards, Michael


The brackets are pointless as all your criteria are ANDed
Also (somecolumn AND '%searcht%') is nonsense.
But apart from that, the order that criteria in a WHERE clause is used
will be worked out by the optimiser, regardless of what order you
write it.

  Réponse avec citation
Vieux 08/11/2007, 11h13   #3
Michael
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Order of WHERE Clausels

On Nov 8, 11:54 am, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On 8 Nov, 10:01, useit...@gmail.com wrote:
>
>
>
>
>
> > Hi all!

>
> > would be a query faster, if I put first day option and then all other
> > like this

>
> > SELECT column FROM bigtable WHERE (date > 2007-01-01 AND date <
> > 2007-01-03) AND (somecolumn AND '%searcht%') AND (category LIKE
> > '%categoryname%')

>
> > or it the same

>
> > SELECT column FROM bigtable WHERE (somecolumn AND '%searcht%') AND
> > (category LIKE '%categoryname%') AND (date > 2007-01-01 AND date <
> > 2007-01-03)

>
> > I mean, the table could be very big, so first day option would be
> > minimize slow LIKE's overhead ?

>
> > Best regards, Michael

>
> The brackets are pointless as all your criteria are ANDed
> Also (somecolumn AND '%searcht%') is nonsense.
> But apart from that, the order that criteria in a WHERE clause is used
> will be worked out by the optimiser, regardless of what order you
> write it.- Hide quoted text -
>
> - Show quoted text -


Thanks for your answer! Indeed it should be (somecolumn LIKE '%searcht
%') . Anyway, I'm glad, that I can ignore the order after WHERE

Regards

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 10h46.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11355 seconds with 11 queries