473,473 Members | 2,144 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with indices

2 New Member
I am executing this query. The execution time is unacceptable (1 minute for 2000 records). Can anybody tell me how i can optimize my sql or my indices in the tables?

Expand|Select|Wrap|Line Numbers
  1. select art.art,art.desc,book1.cust,book1.price
  2. from PUB.art
  3. join PUB.prbk as book1
  4. on art.company='company1'
  5. and art.company=book1.company
  6. and book1.grp='00000526'
  7. and art.art=book1.art
  8. and book1.cust=(
  9. select max(book2.cust)
  10. from PUB.prbk as book2
  11. where book1.company=book2.company
  12. and book1.grp=book2.grp
  13. and book1.art=book2.art
  14. and (book2.cust='BRONFRITUUR' or book2.cust=''))
Table art:
fields: company,art,desc
index: company+art

Table prbk
fields: company,art,grp,cust,price
index: company+grp+art+cust
Nov 28 '07 #1
1 957
mwasif
802 Recognized Expert Contributor
Do you have combine indices on company+art AND company+grp+art+cust?

The following condition in JOIN should go to WHERE instead
art.company='company1'
AND book1.grp='00000526'

Use explain to find out the bottleneck.
Nov 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: dan | last post by:
I was recently surprised, and quite shocked in fact, to find that Python treats negative indices into sequence types as if they were mod(length-of-sequence), at least up to -len(seq). This fact...
5
by: Ross MacGregor | last post by:
I have a very simple yet complicated problem. I want to generate a random list of indices (int's) for a container. Let's say I have a container with 10 items and I want a list of 3 random...
9
by: Randell D. | last post by:
Folks, I can program fairly comfortably in PHP and can, for the most part using these skills and others that I've picked up over the years manage to read/understand most code in Javascript... so...
8
by: laniik | last post by:
Hi. I have a problem using STL's built in sort that seems impossible to get around. if i have: -------------------------------- struct object { int val; }
8
by: Klaus Schneider | last post by:
Hi all! I'm having trouble with a template function with variable arguments when I parse an enum type as variable argument. Example: template <class T> bool test(int num, ...) { va_list ap;...
18
by: mrvendetta1 | last post by:
hi any hints would be great! #include <stdio.h> #define MySize 8 void FindPosition(int array); { int array1 = {0,0,0,0,0,1,0,1}; FindPosition(array1) void FindPosition(int array) { int...
18
by: Joe Blow | last post by:
Can anybody see a problem with this? Am I being stupid? if (!isset($_REQUEST) || "" == $_REQUEST) { throw new Exception("need query"); } else { echo "<p>Search words: $_REQUEST"; }
3
by: GavinCrooks | last post by:
The indices method of slice doesn't seem to work quite how I would expect when reversing a sequence. For example : '43210' '43210' So a slice with a negative step (and nothing else) reverses...
2
by: smichr | last post by:
It seems to me that the indices() method for slices is could be improved. Right now it gives back concrete indices for a range of length n. That is, it does not return any None values. Using an...
2
by: Xavier Barthelemy | last post by:
Hi all I'm becoming mad, because I can't see what's wrong: I am constructing a GUI, to plot some data. so let's have a look of what's wrong: in my code I have a variable named...
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
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
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.