473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How to optimise these 8 queries?

Hi,

I have a database like this:

CREATE TABLE weersgeschiedenis (
WMO enum('06235','06260','06280','06290','06310','0638 0') NOT NULL default
'06235',
YYYYMMDD date NOT NULL default '0000-00-00',
DDVEC smallint(5) unsigned NOT NULL default '0',
FG tinyint(3) unsigned NOT NULL default '0',
FHX smallint(5) unsigned NOT NULL default '0',
FX smallint(5) unsigned NOT NULL default '0',
TG smallint(6) NOT NULL default '0',
TN smallint(6) NOT NULL default '0',
TX smallint(6) NOT NULL default '0',
SQ smallint(6) NOT NULL default '0',
SP tinyint(3) unsigned NOT NULL default '0',
DR tinyint(3) unsigned NOT NULL default '0',
RH smallint(6) NOT NULL default '0',
PG smallint(5) unsigned NOT NULL default '0',
VVN tinyint(3) unsigned NOT NULL default '0',
NG tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (WMO,YYYYMMDD)
) TYPE=MyISAM
For one page I need to have all of the following 8 results:
SELECT WMO,YYYYMMDD,DDVEC,FG,FHX,FX FROM $dbtable WHERE
year(YYYYMMDD)='$year' ORDER BY FX DESC,FHX DESC,YYYYMMDD DESC LIMIT 1

SELECT WMO,YYYYMMDD,DR,RH FROM $dbtable WHERE year(YYYYMMDD)='$year' ORDER
BY RH DESC,DR DESC,YYYYMMDD DESC LIMIT 1

SELECT WMO,YYYYMMDD,TG,TN,TX FROM $dbtable WHERE year(YYYYMMDD)='$year'
ORDER BY TG,TN,YYYYMMDD DESC LIMIT 1

SELECT WMO,YYYYMMDD,TN FROM $dbtable WHERE year(YYYYMMDD)='$year' ORDER BY
TN,YYYYMMDD DESC LIMIT 1

SELECT WMO,YYYYMMDD,TG,SQ,SP FROM $dbtable WHERE year(YYYYMMDD)='$year'
ORDER BY SP DESC,SQ DESC,YYYYMMDD DESC LIMIT 1

SELECT WMO,YYYYMMDD,TG,TN,TX FROM $dbtable WHERE year(YYYYMMDD)='$year'
ORDER BY TG DESC,TX DESC,YYYYMMDD DESC LIMIT 1

SELECT WMO,YYYYMMDD,TX FROM $dbtable WHERE year(YYYYMMDD)='$year' ORDER BY
TX DESC,YYYYMMDD DESC LIMIT 1

SELECT WMO,YYYYMMDD,
(1.41-(0.1162*FG)+(0.0980*TG)+(0.000124*FG*FG)+(0.000185 *FG*TG)) as TEMP
FROM $dbtable WHERE year(YYYYMMDD)='$year' ORDER BY TEMP ASC, YYYYMMDD DESC
LIMIT 1
The total query time is now about 2.10 seconds.
$year is a variable that can be 1901 till 2004.

If you have any tips on how to speed up this query's (maybe by combining?)
please post a reply :)

Thanks,
Wouter
Jul 20 '05 #1
0 1353

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jasper Bryant-Greene | last post by:
Hi I have this query: SELECT id, name, YEAR(born) AS year FROM people WHERE DAYOFMONTH(born) = 7 AND MONTH(born) = 12 ORDER BY year DESC, name
6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
5
by: Robin Tucker | last post by:
I have these 3 queries - they are the same except each fetches record counts for one of 3 different record types, nSubsets (type 0), nAssets (type 1) and nImages (type 2). Is there any way I could...
1
by: Roger Green | last post by:
I have inherited a complex database that has many dozens of queries that derive data from a people table. I now need to be able to run these queries (from within a significant number of forms)...
3
by: NeilAnderson | last post by:
I'm a fairly new user of access & I've never had any training, so I'm wondering if I'm doing the right thing here, or if it matter at all. I'm building a database for room booking purposes and I'm...
5
by: Jerry Hull | last post by:
I'm working with a database developed by an untrained person over several years - and on a network that has recently been upgraded with a new server installed and MS office upgraded from 2K (I...
44
by: Greg Strong | last post by:
Hello All, Is it better to create a query in DAO where a report has 4 sub-reports each of whose record source is a query created at runtime and everything is in 1 MDB file? From what I've...
2
by: Hervé Piedvache | last post by:
Hi, I have may be a stupid question, but I'm a little surprised with some explains I have, using date fields ... I would like to understand exactly when index are used ... I'm using...
1
by: loosecannon_1 | last post by:
Hello everyone, I am hoping someone can help me with this problem. I will say up front that I am not a SQL Server DBA, I am a developer. I have an application that sends about 25 simultaneous...
5
by: Aussie Rules | last post by:
Hi, I have a vb.net 2005 project that has just got slower and slower as I develop. Does anybody know of a code tool to use to to pin point performance problems, and clean up/optimise the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.