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 10min 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 two things:
1. Somebody discouraged the use of composite keys
as in my case, I have never understood why. What
are the pros & cons?
2. What can I 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, after 9years burried
in DBFs with no DBCs)
I am using VFP6 with MSDE 2000 on a Windows 98 box.
Thanks
Benson