Hi friends!
I have a table with 12 months' payroll data for over 17,000 employees. The table has nearly 3 million rows.
The field
I have a table with 12 months' payroll data for over 17,000 employees. The table has nearly 3 million rows.
The field
Code:
has payroll items such as Basic Salary,
Bonus e.t.c. coded with numericals eg 001,100,738 and so on
The field [pfnumber] is employee's personal file no.
I have a primary key defined as follows:
[code]... ADD CONSTRAINT c_period PRIMARY KEY CLUSTERED (YEAR,MONTH,CODE,PFNUMBER)[\code]
my query is as follows:
[code]SELECT PFNUMBER,CODE,AMOUNT,BALANCE,YEAR,MONTH FROM PROCESED WHERE YEAR=2004 AND CODE=738[\code]
It takes over 10 min to process
If I modify it to include a payroll month as follows:
[code]SELECT PFNUMBER,CODE,AMOUNT,BALANCE,YEAR,MONTH FROM PROCESED WHERE YEAR=2004 AND MONTH =1 AND CODE=738[\code]
it takes 6 seconds. Pretty fast!
I need help on:
2. What I can do to speed my first query.
(I do not need the month in it, I need records for
the whole year)
(Please I am learning, the hard way!)
I am using MSDE 2000 on a Windows 98 box.
Thanks
Benson