Re: Efficient SQL Statement

2004-01-21 Thread Roger Baklund
* Chuck Gadd > Roger Baklund wrote: > > >>Either way, I was surprised to see the "like" to be in the top > >>performers and "left()" to be last. > > > > I suppose the LIKE operator is optimized for the case when it > > begins with a constant: > > > > mysql> select BENCHMARK(1000, 'dfsfsdfs' lik

Re: Efficient SQL Statement

2004-01-21 Thread Chuck Gadd
Roger Baklund wrote: Either way, I was surprised to see the "like" to be in the top performers and "left()" to be last. I suppose the LIKE operator is optimized for the case when it begins with a constant: mysql> select BENCHMARK(1000, 'dfsfsdfs' like '%F%' ); 1 row in set (3.43 sec) MySql w

Re: Efficient SQL Statement

2004-01-21 Thread Roger Baklund
* ed aka emierzwa at micron.com > I'm on WinXP, 2.6ghz. mysqld-nt Alpha 4.1.2 w2k, 0.6ghz, 3.23.30-gamma > Either way, I was surprised to see the "like" to be in the top > performers and "left()" to be last. I suppose the LIKE operator is optimized for the case when it begins with a constant:

RE: Efficient SQL Statement

2004-01-21 Thread emierzwa
I'm on WinXP, 2.6ghz. mysqld-nt Alpha 4.1.2 Either way, I was surprised to see the "like" to be in the top performers and "left()" to be last. Ed --- * ed aka emierzwa at micron.com > You could just use the benchmark function? > > select BENCHMARK(1000, 'dfsfsdfs' li

Re: Efficient SQL Statement

2004-01-21 Thread Roger Baklund
* ed aka emierzwa at micron.com > You could just use the benchmark function? > > select BENCHMARK(1000, 'dfsfsdfs' like 'F%' ) /* 0.45 sec. */ > select BENCHMARK(1000, 'dfsfsdfs' between 'F' and 'Fzzz' ) /* 0.55 > sec. */ > select BENCHMARK(1000, left('dfsfsdfs',1)='F' ) /* 0.79 sec.

RE: Efficient SQL Statement

2004-01-21 Thread emierzwa
7;,1)='F' ) /* 0.79 sec. */ The times go up a little if the strings are a match. Ed -Original Message- From: Roger Baklund [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 1:11 PM To: [EMAIL PROTECTED] Cc: Hassan Shaikh Subject: Re: Efficient SQL Statement * Hassan Shaikh

Re: Efficient SQL Statement

2004-01-21 Thread Roger Baklund
* Hassan Shaikh > Which one of the following statements is more efficient? > > SELECT * FROM COUNTRY WHERE LEFT(CNNAME,1)='B'; > > Or > > SELECT * FROM COUNTRY WHERE CNNAME LIKE 'B%'; The second statement will normally be the most effective, because the server don't need to perform a function on t

Efficient SQL Statement

2004-01-21 Thread Hassan Shaikh
Hi All, Which one of the following statements is more efficient? SELECT * FROM COUNTRY WHERE LEFT(CNNAME,1)='B'; Or SELECT * FROM COUNTRY WHERE CNNAME LIKE 'B%'; Thanks. Hassan -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.my