473,769 Members | 6,120 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,1 9,22,24,26,63,2 8,29,30,32,40,5 2,68,48,49,37,5 4,39,73,43,44,7 7,45,57,55,65,6 6,74,103,78,82, 84,85,86,88,90, 91,92,93,99,95, 96,97,98,100,10 4,105,106,107,1 08,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,1 9,22,24,26,63,2 8,29,30,32,40,5 2,68,48,49,37,5 4,39,73,43,44,7 7,45,57,55,65,6 6,74,103,78,82, 84,85,86,88,90, 91,92,93,99,95, 96,97,98,100,10 4,105,106,107,1 08,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 2067

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,1 9,22,24,26,63,2 8,29,30,32,40,5 2,68,48,49,37,5 4,39,73,43,44,7 7,45,57,55,65,6 6,74,103,78,82, 84,85,86,88,90, 91,92,93,99,95, 96,97,98,100,10 4,105,106,107,1 08,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,1 9,22,24,26,63,2 8,29,30,32,40,5 2,68,48,49,37,5 4,39,73,43,44,7 7,45,57,55,65,6 6,74,103,78,82, 84,85,86,88,90, 91,92,93,99,95, 96,97,98,100,10 4,105,106,107,1 08,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,1 9,22,24,26,63,2 8,29,30,32,40,5 2,68,48,49,37,5 4,39,73,43,44,7 7,45,57,55,65,6 6,74,103,78,82, 84,85,86,88,90, 91,92,93,99,95, 96,97,98,100,10 4,105,106,107,1 08,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,1 9,22,24,26,63,2 8,29,30,32,40,5 2,68,48,49,37,5 4,39,73,43,44,7 7,45,57,55,65,6 6,74,103,78,82, 84,85,86,88,90, 91,92,93,99,95, 96,97,98,100,10 4,105,106,107,1 08,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
2547
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 very, very slow as the number of records grows - somewhere in the number of 5,000,000. I imagine queries are much faster but am not quite sure if queries will do the trick. My problem:
5
4304
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 could retrieve all the records for a specific date if I hard-code the date into the query, but not if I want to prompt the user. Has anybody else experienced this? Does anybody have any suggestions?
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 make a query that selects from a table as desribed below .. I have a table (Volunteer) that has a member field (memnumber) and a number of fields that are headed in various categories and are yes/no formated
3
1515
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 qualify for newsletter No.1. The are displayed using a subform for viewing purposes. What I want to do now (in one swift action) is to add the customer account no's to the table 'CustLett' along with the ID of Newsletter No.1. I think I can do...
6
2299
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 table named {Table of Revisions}. It naturally matches them up by linking the autoid in {Doc} with the related field in {Rev}. It then looks for a field in {Rev} called "revision number" and looks for the last one for the given Doc (linked by the...
1
1873
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 training. I will explain my structure before asking my questions. I have data from a table (updated monthly by adding the most current month’s data) that is evaluated by certain arithmetic, given an adjective to describe it, and then being exported...
1
1398
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 that separates the bids in one field and the offers in another one (plus many other fields). I have created 2 queries, one that shows all the bids for all portfolios and another one that shows all the offers. The problem comes when I try to create...
8
1521
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 replaced with strage characters like "ᘈ" or "ᘈ". When removing the totals the forenames are all shown normally again. I have checked the underlying table which contains the field and there is nothing wrong with the data in there. I have also checked...
5
1468
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 TblNme.* where OffCde='123' or
0
9424
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
10223
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
10000
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
8879
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...
0
6675
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
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
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.