473,503 Members | 1,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query slower when selecting a different field


Hello,

I have a table called BUILDREQUESTS which I want to select from,
depending on the project ID of each record. The Project ID field is
indexed.

(A) This query runs almost instantly:

SELECT BR.REQID FROM BUILDREQUESTS BR WHERE BR.PROJECTID IN
(1,62,56,3,4,2,15,9,11,17,18,19,22,24,26,63,28,29, 30,32,40,52,68,48,49,37,54,39,73,43,44,77,45,57,55 ,65,66,74,103,78,82,84,85,86,88,90,91,92,93,99,95, 96,97,98,100,104,105,106,107,108,109,110,111);

(B) This query takes about 1.7 seconds:

SELECT BR.REQUESTEDBY FROM BUILDREQUESTS BR WHERE BR.PROJECTID IN
(1,62,56,3,4,2,15,9,11,17,18,19,22,24,26,63,28,29, 30,32,40,52,68,48,49,37,54,39,73,43,44,77,45,57,55 ,65,66,74,103,78,82,84,85,86,88,90,91,92,93,99,95, 96,97,98,100,104,105,106,107,108,109,110,111);

Note that the only difference between Query A and Query B is the field
we are selecting. REQID and REQUESTEDBY by are both Int(11) fields.
The only difference between the two fields is that REQID is indexed.
Neither of these fields are in the WHERE clause and there is no sort
order, so what gives? Why the slowdown? Ideally, I want to select
several more fields, but this is my test case to try and optimize first.

The machine I am running on is fast, single CPU, 512M RAM. MySql 3.23,
default install via Red Hat 8. I have tried tweaking several buffer
settings in my.cnf to no avail.

What am I missing!?

Thanks,
John
Jul 19 '05 #1
2 2053

The only thing I can think of so far, and I'm not sure what to do about
it, is that the table is "Dynamic", not "Fixed". Perhaps jumping around
from record to record is causing the slowdown, as there are multiple
text columns in the table. The select on reqid is fast, because it is
an indexed field and there is no need to go to the table data to get the
value. Problem is that I cannot index every field I want to display.

John
John wrote:

Hello,

I have a table called BUILDREQUESTS which I want to select from,
depending on the project ID of each record. The Project ID field is
indexed.

(A) This query runs almost instantly:

SELECT BR.REQID FROM BUILDREQUESTS BR WHERE BR.PROJECTID IN
(1,62,56,3,4,2,15,9,11,17,18,19,22,24,26,63,28,29, 30,32,40,52,68,48,49,37,54,39,73,43,44,77,45,57,55 ,65,66,74,103,78,82,84,85,86,88,90,91,92,93,99,95, 96,97,98,100,104,105,106,107,108,109,110,111);
(B) This query takes about 1.7 seconds:

SELECT BR.REQUESTEDBY FROM BUILDREQUESTS BR WHERE BR.PROJECTID IN
(1,62,56,3,4,2,15,9,11,17,18,19,22,24,26,63,28,29, 30,32,40,52,68,48,49,37,54,39,73,43,44,77,45,57,55 ,65,66,74,103,78,82,84,85,86,88,90,91,92,93,99,95, 96,97,98,100,104,105,106,107,108,109,110,111);
Note that the only difference between Query A and Query B is the field
we are selecting. REQID and REQUESTEDBY by are both Int(11) fields. The
only difference between the two fields is that REQID is indexed. Neither
of these fields are in the WHERE clause and there is no sort order, so
what gives? Why the slowdown? Ideally, I want to select several more
fields, but this is my test case to try and optimize first.

The machine I am running on is fast, single CPU, 512M RAM. MySql 3.23,
default install via Red Hat 8. I have tried tweaking several buffer
settings in my.cnf to no avail.

What am I missing!?

Thanks,
John

Jul 19 '05 #2

The only thing I can think of so far, and I'm not sure what to do about
it, is that the table is "Dynamic", not "Fixed". Perhaps jumping around
from record to record is causing the slowdown, as there are multiple
text columns in the table. The select on reqid is fast, because it is
an indexed field and there is no need to go to the table data to get the
value. Problem is that I cannot index every field I want to display.

John
John wrote:

Hello,

I have a table called BUILDREQUESTS which I want to select from,
depending on the project ID of each record. The Project ID field is
indexed.

(A) This query runs almost instantly:

SELECT BR.REQID FROM BUILDREQUESTS BR WHERE BR.PROJECTID IN
(1,62,56,3,4,2,15,9,11,17,18,19,22,24,26,63,28,29, 30,32,40,52,68,48,49,37,54,39,73,43,44,77,45,57,55 ,65,66,74,103,78,82,84,85,86,88,90,91,92,93,99,95, 96,97,98,100,104,105,106,107,108,109,110,111);
(B) This query takes about 1.7 seconds:

SELECT BR.REQUESTEDBY FROM BUILDREQUESTS BR WHERE BR.PROJECTID IN
(1,62,56,3,4,2,15,9,11,17,18,19,22,24,26,63,28,29, 30,32,40,52,68,48,49,37,54,39,73,43,44,77,45,57,55 ,65,66,74,103,78,82,84,85,86,88,90,91,92,93,99,95, 96,97,98,100,104,105,106,107,108,109,110,111);
Note that the only difference between Query A and Query B is the field
we are selecting. REQID and REQUESTEDBY by are both Int(11) fields. The
only difference between the two fields is that REQID is indexed. Neither
of these fields are in the WHERE clause and there is no sort order, so
what gives? Why the slowdown? Ideally, I want to select several more
fields, but this is my test case to try and optimize first.

The machine I am running on is fast, single CPU, 512M RAM. MySql 3.23,
default install via Red Hat 8. I have tried tweaking several buffer
settings in my.cnf to no avail.

What am I missing!?

Thanks,
John

Jul 19 '05 #3

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

Similar topics

2
2526
by: Willem | last post by:
Hi there, I'm sort of new with doing much record manipulation with queries. Up till now I've been programming VBA and doing record looping to get my results. This works fine but tends to get...
5
4276
by: Javier | last post by:
I have a field type Date/Time that automatically defaults to Now(). I'm having a problem writing a query that will retrieve all the records for a specific date the user to enters when prompted. I...
3
579
by: John young | last post by:
I have been looking for an answer to a problem and have found this group and hope you can assist . I have been re doing a data base I have made for a car club I am with and have been trying to...
3
1493
by: Steve Housechild | last post by:
I have a table of 'Customers', a table of 'Newsletters' and a table for storing which customers have recieved which letters 'CustLett'. By using a query, I have pulled a list of customers who...
6
2272
by: Larry R Harrison Jr | last post by:
I have a database I'm designing in Access 97. I have a custom field in a query which looks in {Table of Documents} and shows them all. It then needs a "latest revision number," stored in another...
1
1858
by: commodityintelligence | last post by:
Greetings, I am merging a series of different tables into one query to export decision-making information. I have some architecture issues I need to ask for help on. I have no programming...
1
1383
by: johnniewalkeresp | last post by:
Hi, I'm having trouble with the following: I have a portfolio table with a field called "Bid/Offer" which is filled in by selecting Bid or Offer from a combo box. Now I need to create a query...
8
1506
by: Lewe22 | last post by:
I have a basic query which is selecting all information from another query . As soon as i set the query to show the totals (in order to perform a sum) all information held in a field named is...
5
1447
by: bobh | last post by:
Hi All, Is there a difference in preformance between the two; TblNme has 36 fields across a record a query that selects all fields and the report only uses 75% of the fields, ie; Select...
0
7201
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
7278
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
7328
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
5578
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,...
1
5011
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...
0
4672
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
1510
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 ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.