| List: | General Discussion | « Previous MessageNext Message » | |
| From: | Eugene Kosov | Date: | June 21 2006 9:44pm |
| Subject: | Re: query slow | ||
| View as plain text | |||
luiz Rafael wrote: > SELECT * FROM `sav00_sava0400_dbf` WHERE 2000 = YEAR(`emissao`) OR > (1999 = YEAR(`emissao`) AND 12 < MONTH(`emissao`)) ORDER BY emissao ASC Are you sure this is what you really want? MONTH() is never greater than 12, so your query is equal to: SELECT * FROM `sav00_sava0400_dbf` WHERE 2000 = YEAR(`emissao`) ORDER BY emissao In order to make your query work faster you should create an index on `emissao` and rewrite it using date ranges. So you query will become something like this (if you actually meant December'99 and whole year 2000): SELECT * FROM `sav00_sava0400_dbf` WHERE `emissao` BETWEEN '1999-12-01 00:00:00' AND '2000-12-31 23:59:59'; -- BR, Eugene Kosov
| Thread | ||
|---|---|---|
| • Just need script for creating tables | Xiaobo Chen | 21 Jun |
| • Re: Just need script for creating tables | Daniel da Veiga | 21 Jun |
| • RE: Just need script for creating tables | Peter Lauri | 21 Jun |
| • query slow | luiz Rafael | 21 Jun |
| • Re: query slow | Jay Pipes | 21 Jun |
| • Re: query slow | Eugene Kosov | 21 Jun |
| • Re: query slow | Eugene Kosov | 21 Jun |
| • Re: query slow | luiz Rafael | 21 Jun |
| • reclaim disk space | luiz Rafael | 21 Jun |
| • Re: reclaim disk space | Dan Buettner | 21 Jun |
| • Re: reclaim disk space | Dan Nelson | 21 Jun |
| • Re: query slow | luiz Rafael | 25 Jun |
| • Re: Just need script for creating tables | Martin Jespersen | 21 Jun |
| • RE: reclaim disk space | George Law | 21 Jun |
