Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

slow running sql question

Status
Not open for further replies.

thompom

Technical User
Dec 4, 2006
395
GB
hi - am running the following query and seems to take ages.
i am not using mysql but an unknown database system on a unix box - i have no control over the database but have purchased an odbc driver that seems very 'clunky' after using mysql - this is an sql statement question rather than a mysql tech question.

if i run this
Code:
SELECT
MK_01_vehicleRecords.registrationnumber, MK_01_VehicleRecords.vehiclenumber
FROM MK_01_VehicleRecords
WHERE (MK_01_VehicleRecords.vehiclenumber = '36176')

it takes less than a second

however if i run this
Code:
SELECT
MK_01_vehicleRecords.registrationnumber, MK_01_VehicleRecords.vehiclenumber
FROM MK_01_VehicleRecords
WHERE (MK_01_VehicleRecords.vehiclenumber = '36176'
OR MK_01_VehicleRecords.vehiclenumber = '109786'
OR MK_01_VehicleRecords.vehiclenumber = '115970'
OR MK_01_VehicleRecords.vehiclenumber = '126969'
OR MK_01_VehicleRecords.vehiclenumber = '131468'
OR MK_01_VehicleRecords.vehiclenumber = '136116'
OR MK_01_VehicleRecords.vehiclenumber = '138911'
OR MK_01_VehicleRecords.vehiclenumber = '202313'
OR MK_01_VehicleRecords.vehiclenumber = '202593'
OR MK_01_VehicleRecords.vehiclenumber = '204048')

it takes 5+ secs - is there something wrong with this sql statement ? - anything i can try to speed it up?
 
an unknown database" :)

try this:
Code:
WHERE MK_01_VehicleRecords.vehiclenumber 
      IN ('36176'
        , '109786'
        , '115970'
        , ... )

r937.com | rudy.ca
 
hi rudy - tried that and seemed a second quicker! but still takes too long :(

im afraid to say that my unix knowledge is poor and i dont know how to find out the db on this 3rd party managed application - i heard it was based on something called wang2000?
 
you could try "show index from tablename"

You're looking to see if the field `vehiclenumber` is indexed, as that would make a huge difference to speed.

How you'd go about changing that is anyones guess tho.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top