473,795 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join using temporary, filesort

I asked this a couple days ago, but never got an answer, so I'll try to
include some more detail:

MySQL 4.0.12 on linux 2.4.18...

I'm doing a join on 2 tables and trying to optimize it but I always end up
with "Using temporary; Using filesort" and the query takes way too long...

What can I do to speed this up?

Here's my tables:

CREATE TABLE `metardata` (
`stn` char(4) NOT NULL default '',
`Hr` int(2) NOT NULL default '0',
`min` int(2) NOT NULL default '0',
`Day` int(2) NOT NULL default '0',
`wmoid` int(10) default NULL,
`temp` decimal(6,2) NOT NULL default '0.00',
`rh` decimal(6,2) default NULL,
`wdsp` decimal(6,2) default NULL,
`wddir` char(2) default NULL,
`dwpt` decimal(6,2) default NULL,
`lpre` decimal(6,2) default NULL,
`yearmoda` date NOT NULL default '0000-00-00',
PRIMARY KEY (`stn`,`yearmod a`,`Hr`,`min`)
) TYPE=MyISAM

CREATE TABLE `FcstHr_avn` (
`model` varchar(12) NOT NULL default '',
`yearmoda` date NOT NULL default '0000-00-00',
`modelruntime` int(2) NOT NULL default '0',
`modelhr` int(3) NOT NULL default '0',
`fyearmoda` date NOT NULL default '0000-00-00',
`fhr` int(2) NOT NULL default '0',
`stn` varchar(4) NOT NULL default '',
`temp` decimal(6,2) default NULL,
PRIMARY KEY (`yearmoda`,`mo delruntime`,`mo delhr`,`stn`),
KEY `stn` (`stn`,`fyearmo da`,`fhr`),
KEY `fcst` (`stn`,`yearmod a`,`modelruntim e`)
) TYPE=MyISAM MAX_ROWS=429496 7295
explain gives me this output:
mysql> explain select modelruntime, modelhr, avg(m.temp-f.temp) from
metardata as m, FcstHr_avn as f where m.yearmoda=f.fy earmoda and m.stn=f.stn
and m.hr=f.fhr and m.yearmoda='200 3-07-01' and m.stn='kdro' group by
modelruntime+mo delhr;
+-------+------+---------------+---------+---------+-----------------------+
------+----------------------------------------------+
| table | type | possible_keys | key | key_len | ref |
rows | Extra |
+-------+------+---------------+---------+---------+-----------------------+
------+----------------------------------------------+
| m | ref | PRIMARY | PRIMARY | 7 | const,const |
18 | Using where; Using temporary; Using filesort |
| f | ref | stn,fcst | stn | 11 | const,m.yearmod a,m.Hr |
27 | Using where |
+-------+------+---------------+---------+---------+-----------------------+
------+----------------------------------------------+
2 rows in set (0.01 sec)

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/my***********...ie.nctu.edu.tw

Jul 19 '05 #1
0 4342

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

Similar topics

5
33660
by: Jim Garrison | last post by:
Scenario: 1) Create a GLOBAL TEMPORARY table and populate it with one (1) row. 2) Join that table to another with about 1 million rows. The join condition selects a few hundred rows. Performance: 4 seconds, the system is doing a full-table scan of the second table, and the Explain Plan output
0
1345
by: Tom O'Neill | last post by:
Could anyone tell me the difference between the following two explains? It seems the first takes longer to execute. This first query is like so... select m.*, mi.age from members m, members_addtl_info mi where m.nick like '%anynickname%' AND m.nick = mi.nick order by nick desc, account_login_last desc limit 0, 21 +-------+--------+---------------+---------+---------+---------+--------+---
0
2240
by: Jan Persson | last post by:
Hi, I am having trouble optimizing the query: select * from article order by article_id; for a MyISAM table that looks like this: CREATE TABLE `article` ( `id` int(11) NOT NULL auto_increment,
0
1309
by: Mark Smith | last post by:
Hello: I have two tables: D (500,000 recs), and DL (2,500,000 recs) D has a PK and an index on HLQ. DL has a PK and an index on ID. The following SQL: SELECT HLQ as "HLQ",
4
1371
by: Denis St-Michel | last post by:
Hello All, Hope some Guru will be able to help me with this. Let's take this example table A ------------------------------------------------------------------------------- id | TicketNo | evaluation | Username ------------------------------------------------------------------------------- 1 1 9 Jamie 2 1 8.5 ...
0
1037
by: Joe | last post by:
I'm trying to get the following query optimized: SELECT box.box_id, box.phone_number, buildings.name as building_name, buildings.id as building_id, accounts.name as account_name from boiler_on_off_date LEFT join box ON box.box_id=boiler_on_off_date.box_id LEFT join buildings FORCE INDEX (id) ON buildings.id = box.building_id LEFT join accounts ON accounts.id = buildings.owner_id WHERE boiler_on_off_date.timestamp > '2005-10-05' GROUP by...
7
2915
by: stabbert | last post by:
I am attempting to join two tables together on two different unix servers. Here is some relevant info about the tables. TABLE 1 Setup ----------------------- DB2 UDB 7.2 EE
4
2096
by: kamin | last post by:
I have this query select created_date, tyg_aging_due_dates.object_type, tyg_aging_due_dates.due_date from #tyg_aging_service_metrics right join tyg_aging_due_dates
4
2718
by: polycom | last post by:
Assistance needed to optimize this query SELECT SD.content_id AS Id, SD.title AS Title, CT.name AS Contenttype, PV.content_id AS SponsorId, PV.display_name AS Sponsor, CONCAT_WS("", NT.title, " - ", N.pubdate, " ") AS ListGroup,
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10437
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10164
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.