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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select from tables having 10 lakh records

Status
Not open for further replies.

balachandar

Programmer
Apr 16, 2001
88
CA
Friends,
I have two tables.
the table has the structure
the table T
uniqueid(integer) clientname char(15) entrydate(datetime) profit(money).
the second table I has the following structure(for every
uniqueid in table T there can be 4 to 8 rows in I)

uniqueid indicator code


now from T for every clientname i have to find the set of uniqueid
and use them to find the corresponding rows In I. if the
field indicator is 1,then it is a 'pass' record. similarly 2 indicates a 'fail' record. and the records having codes 1,2,11,12 alone are to be selected.
The output should be as follows

Clientname monthlycountofpassuniqueids,monthly count of failed uniqueid's,yearly count of passed unique id's and
yearly count of failed unique ids. the query we wrote was

select customername
Mpasscount,
Mfailedcount
from
(select customername,
count(uniqueid) as 'mpasscount'
from (select customer_name,uniqueid from T
where entrydate between '2001-05-01' and '2001- 05- 21' ) as
Tdummy,
(select distinct uniqueid from I where bsell=1
and code in(1,2,11,12) as
Idummy
where tdummy.uniqueid =idummy.uniqueid)as
A,
(select customername,count(uniqueid)as 'msellcount'
from (select customer_name,uniqueid from T
where entrydate between '2001-05-01' and '2001-05- 21' ) as
Tdummy,
(select distinct uniqueid from I where bsell=2
and code in(1,2,11,12) as Idummy
where tdummy.uniqueid =idummy.uniqueid)as
B

where
a.customername=b.customername

this works fine. however as we have nealy 2.5lakh records in T and 10 lakh records in I , the perfomance is becoming a big issue. the same thing i did for yearly pass fail count as well.
Please suggest methods,or similar queries to increase the perfomance. the maximum time frame for the query is 24 seconds.or even if the query has to be reconstructed pleae guide us an how to do that
Thanks and Regards
Balachandar




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top