|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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 |
|
![]() |
| Outils de la discussion | |
|
|