ORDER BY LIMIT issue

2010-08-04 Thread Kristian Davies
With the following query if I it returns 2 results it's fast .04s, if it has less results than the limit it takes 1minute. Query: select * from hub_dailies_sp where active='1' and date='2010-08-04' order by id desc LIMIT 2; Show create table: http://pastebin.org/447171 27,000 rows in

Re: ORDER BY LIMIT issue

2010-08-04 Thread Eigo Mori
Hi, With the following query if I it returns 2 results it's fast .04s, if it has less results than the limit it takes 1minute. Query: select * from hub_dailies_sp where active='1' and date='2010-08-04' order by id desc LIMIT 2; Show create table: http://pastebin.org/447171 27,000

Re: ORDER BY LIMIT issue

2010-08-04 Thread Kristian Davies
Isn't it so that it firstly order the rows by id (index'ed?) and then scan  it to pick the rows which satisfy the where clause? It stops when the result reaches the limit, otherwise scans the whole (27, 000 rows scan). Then the response time with 2 rows limit by 2 can really depend. If the

RE: ORDER BY LIMIT issue

2010-08-04 Thread Jerry Schwartz
. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 E-mail: je...@gii.co.jp Web site: www.the-infoshop.com -Original Message- From: Kristian Davies [mailto:kristian.dav...@gmail.com] Sent: Wednesday, August 04, 2010 5:03 AM To: mysql@lists.mysql.com Subject: ORDER BY LIMIT issue