ok i have a database, 4 tables.
table 1 - "ATBAT" it contains 1,400,000 records
table 2 - "RESULT" has 130 records
table 3 - "PLAYER" has 2500 records
table 4 - "TEAM" has 30 records
so i do a SELECT on ATBAT and that gives me 1.4 mil records, too much and i go to GROUP BY RESULT, PLAYER and it goes down quite a bit. now it runs in 6-8 seconds. ATBAT contains links to the other three unrealated sibling tables.
ok - so i am at 6 seconds - this is ok for me.
but.
i would like to have the user select from the three other tables any criteria they want. like 20 of the 30 teams, 2 of the players, or all of them or whatever combination. this i have written - works fine.
but but but!!! when i do the joins on the ATBAT table, ( left outers ) and run the select it takes over 4 minutes to return the data. i dont get errors and the RS is correct - but its soooo freeakin sloooow.
could someone write the select statement - i feel i am probably just mis-writing it. maybe use a SELECT inside another SELECT? to whittle stuff down? when i attach just ONE join - any of the three and run it, it comes back in 6-8 seconds - so when i add the next one i get SLOW... :
select result, player, sum(hits) as hits from ATBAT
left join PLAYERS ON ATBAT.player_name=PLAYERS.name
left join TEAM ON ATBAT.team_name=TEAM.name
left join RESULT ON ATBAT.result_name=RESULT.name
where PLAYERS.export='Y' and TEAM.export='Y' and RESULT.export='Y'
group by result, player
order by result, player
could i somehow select between 2 tables, this takes 8 seconds, and use that result set to then select off (exclude) more records based on a third table and then do it one more time with a fourth table? seems it would get much faster each time.
especially with the grouping in the first part. somehow select ATBAT joined with TEAM then have just a few thousand records and the last two would go really fast?!?!?!
eeek.
thanks
table 1 - "ATBAT" it contains 1,400,000 records
table 2 - "RESULT" has 130 records
table 3 - "PLAYER" has 2500 records
table 4 - "TEAM" has 30 records
so i do a SELECT on ATBAT and that gives me 1.4 mil records, too much and i go to GROUP BY RESULT, PLAYER and it goes down quite a bit. now it runs in 6-8 seconds. ATBAT contains links to the other three unrealated sibling tables.
ok - so i am at 6 seconds - this is ok for me.
but.
i would like to have the user select from the three other tables any criteria they want. like 20 of the 30 teams, 2 of the players, or all of them or whatever combination. this i have written - works fine.
but but but!!! when i do the joins on the ATBAT table, ( left outers ) and run the select it takes over 4 minutes to return the data. i dont get errors and the RS is correct - but its soooo freeakin sloooow.
could someone write the select statement - i feel i am probably just mis-writing it. maybe use a SELECT inside another SELECT? to whittle stuff down? when i attach just ONE join - any of the three and run it, it comes back in 6-8 seconds - so when i add the next one i get SLOW... :
select result, player, sum(hits) as hits from ATBAT
left join PLAYERS ON ATBAT.player_name=PLAYERS.name
left join TEAM ON ATBAT.team_name=TEAM.name
left join RESULT ON ATBAT.result_name=RESULT.name
where PLAYERS.export='Y' and TEAM.export='Y' and RESULT.export='Y'
group by result, player
order by result, player
could i somehow select between 2 tables, this takes 8 seconds, and use that result set to then select off (exclude) more records based on a third table and then do it one more time with a fourth table? seems it would get much faster each time.
especially with the grouping in the first part. somehow select ATBAT joined with TEAM then have just a few thousand records and the last two would go really fast?!?!?!
eeek.
thanks