473,396 Members | 2,129 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,396 software developers and data experts.

Query is really slow

I am making an order system and I have 20,000 orders and 100,000 line
items. I keep track of the status for each order so there will me more
then 1 status for each order. I want to check to see if the status ID
is not equal to 12 when ordering by the status date. I am not check for
the 12 value and it's taking for ever to load. Do you know what the
problem is?

select line_ord.row_ID, line_ord.record, customer.customer_type,
customer.company_name,
customer.company_abrv, line_ord.item, line_ord.`list`,
line_ord.itemqty, orders.casedisc,
orders.fhdisc, orders.sstopdisc, orders.ex_rate, line_ord.date_,
line_ord.moddate, line_ord.delrev
from mott.line_ord
INNER JOIN mott.orders ON orders.record = line_ord.record
INNER JOIN mott.customer ON customer.customer_ID = orders.custnum
LEFT OUTER JOIN orders.status ON status.record = line_ord.record
where (date_ between '2005-11-01' and '2005-12-24') or
((moddate between '2005-11-01' and '2005-12-24') and delrev > 0)
and not line_ord.list = 0
group by row_ID
order by date_ asc, status.date desc
PS delrev is when the line item has been deleted in the order's
revision. So I am checking for added and deleted items
Thank you,

Mike

Dec 19 '05 #1
1 1261
"Mike" <po******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
it's taking for ever to load. Do you know what the problem is?


You can get some information about the query performance and which indexes
it's using to speed up the query by using the EXPLAIN keyword.
See: http://dev.mysql.com/doc/refman/5.0/en/explain.html

Make sure you have indexes defined for the fields used in join conditions.
It may also improve things if you create indexes on fields on which you
sort, and the fields used in the WHERE clause.

Also I'm not sure why you're using GROUP BY in your query. You aren't
calculating any aggregate functions, and you're grouping by a field which I
infer is a unique field. Either the GROUP BY has no effect in this case, or
else it's collapsing some rows to one (a peculiar use of GROUP BY in MySQL),
and thus hiding information that could potentially be important.

Regards,
Bill K.
Dec 20 '05 #2

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

Similar topics

2
by: Tim Fountain | last post by:
We've recently enabled slow query logging on a server and it's proving interesting seeing which queries are bogging things down. This one is puzzling me a little: SELECT articleid, type,...
3
by: Brian Oster | last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a query that used to execute in under 2 seconds, now takes over 8 Minutes to complete. Any ideas on what the heck might be going...
1
by: Gary Wales | last post by:
We have two main query types running against a table of some 2 million rows and have gotten query response down to well under a second by using the right indexes. Problem is that we are running...
7
by: Thomi Baechler | last post by:
Hello Everybody I run the following query against to identical databases. Execution time on the first DB is 0 seconds, on the other 6 seconds! SELECT dbo.HRMABZ.EMPKEY ,...
16
by: Dave Weaver | last post by:
I'm having severe performance issues with a conceptually simple database. The database has one table, containing weather observations. The table currently has about 13.5 million rows, and is being...
3
by: Janross | last post by:
I'm having trouble with a query that's prohibitively slow. On my free-standing office computer it's fine (well, 2-4 seconds), but on the client's network, it takes at least 5 minutes to run. ...
4
by: pmacdiddie | last post by:
I have an append query that needs to run every time a line item is added to a subform. The append writes to a table that is the source for a pull down box. Problem is that it takes 5 seconds to...
29
by: wizofaus | last post by:
I previously posted about a problem where it seemed that changing the case of the word "BY" in a SELECT query was causing it to run much much faster. Now I've hit the same thing again, where...
9
by: Bob Darlington | last post by:
The following query opens slowly the first time it is opened (6-7 seconds), but then is less than one second for the next random number of openings before slowing (6-7 seconds) again. SELECT...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
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...

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.