Latest News: OOTP PATCH 9.2.2 released! - OOTP 9 RELEASED! - Title Bout Championship Boxing 2.5 released! - OOTP 2007 receives Editors Choice Award from PC Gamer - Inside the Park Baseball Patch 1.03 released, DEMO now available

Click here to download Out of the Park Baseball 9!

Go Back   OOTP Developments Forums > OUT OF THE PARK BASEBALL 9 > OOTP 9 - Mods > Database Tools
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Database Tools Do you need to take a dump? SQL gurus welcome

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-15-2007, 05:43 PM   #1 (permalink)
BMW
Minors (Triple A)
 
BMW's Avatar
 
Join Date: May 2003
Location: New Jersey
Posts: 258
"Missing" indexes in MySQL

I have "Missing" with quotes, because there's always the tradeoff between storage space/performance.

There were a number of tables that are missing PRIMARY and/or indexes. Running these against your database should fix them up.

I haven't used these for an extended period of time, but I believe the worst error you would be likely to run into is that it cannot apply the index if there is a repeated key (i.e. In human_manager_history, there is more than one record for the same Manager, Managing the same Team, in the same Year. Yes, the way OOTP works, this should not happen, but a database cares not about OOTP and how managers work, it's just looking at a bunch of numbers.)

I didn't use a PRIMARY on the players_at_bat_batting_stats table, because even it doesn't happen often, a batter could face a pitcher twice within the same inning.

Code:
	ALTER TABLE `human_manager_history` ADD PRIMARY KEY ( `human_manager_id` , `team_id` , `year` ) ;
	ALTER TABLE `human_manager_history_batting_stats` ADD PRIMARY KEY ( `human_manager_id` , `team_id` , `year` ) ;
	ALTER TABLE `human_manager_history_fielding_stats_stats` ADD PRIMARY KEY ( `human_manager_id` , `team_id` , `year` ) ;
	ALTER TABLE `human_manager_history_financials` ADD PRIMARY KEY ( `human_manager_id` , `team_id` , `year` ) ;
	ALTER TABLE `human_manager_history_pitching_stats` ADD PRIMARY KEY ( `human_manager_id` , `team_id` , `year` ) ;
	ALTER TABLE `human_manager_history_record` ADD PRIMARY KEY ( `human_manager_id` , `team_id` , `year` ) ;
	ALTER TABLE `league_events` ADD PRIMARY KEY ( `league_id` , `start_date` , `type` ) ;
	ALTER TABLE `league_history` ADD PRIMARY KEY ( `league_id` , `sub_league_id` , `year` ) ;
	ALTER TABLE `league_history_all_star` ADD PRIMARY KEY ( `league_id` , `sub_league_id` , `year` , `all_star_pos` ) ;
	ALTER TABLE `league_history_batting_stats` ADD PRIMARY KEY ( `year` , `league_id` ) ;
	ALTER TABLE `league_history_fielding_stats` ADD PRIMARY KEY ( `year` , `league_id` , `sub_league_id` ) ;
	ALTER TABLE `league_history_pitching_stats` ADD PRIMARY KEY ( `year` , `league_id` ) ;
	ALTER TABLE `league_playoffs` ADD PRIMARY KEY ( `league_id` ) ;
	ALTER TABLE `league_playoff_fixtures` ADD PRIMARY KEY ( `league_id` , `team_id0` , `team_id1` ) ;
	ALTER TABLE `players_at_bat_batting_stats` ADD INDEX ( `player_id` ) ;
	ALTER TABLE `players_at_bat_batting_stats` ADD INDEX ( `game_id` ) ;
	ALTER TABLE `players_at_bat_batting_stats` ADD INDEX ( `opponent_player_id` ) ;
	ALTER TABLE `players_at_bat_batting_stats` ADD INDEX ( `team_id` ) ;
	ALTER TABLE `players_awards` ADD PRIMARY KEY ( `player_id` , `award_id` , `year` , `day` , `month` ) ;
	ALTER TABLE `players_career_batting_stats` ADD PRIMARY KEY ( `player_id` , `year` , `team_id` , `split_id` ) ;
	ALTER TABLE `players_career_fielding_stats` ADD PRIMARY KEY ( `player_id` , `year` , `team_id` , `split_id` , `position` ) ;
	ALTER TABLE `players_career_pitching_stats` ADD PRIMARY KEY ( `player_id` , `year` , `team_id` , `split_id` ) ;
	ALTER TABLE `players_game_batting` ADD PRIMARY KEY ( `player_id` , `year` , `team_id` , `game_id` ) ;
	ALTER TABLE `players_game_pitching_stats` ADD PRIMARY KEY ( `player_id` , `year` , `team_id` , `game_id` ) ;
	ALTER TABLE `players_individual_batting_stats` ADD PRIMARY KEY ( `player_id` , `opponent_id` ) ;
	ALTER TABLE `players_league_leader` ADD PRIMARY KEY ( `player_id` , `sub_league_id` , `year` , `category` ) ;
	ALTER TABLE `players_streak` ADD PRIMARY KEY ( `player_id` , `league_id` , `streak_id` , `started` ) ;
BMW is offline   Reply With Quote
Old 04-16-2007, 12:08 PM   #2 (permalink)
Hall Of Famer
 
Comedian2004's Avatar
 
Join Date: Nov 2004
Location: In a house in Saint Cloud, Florida.
Posts: 6,398
Some of the tables are not really tables, but are in a sort of way. What I mean is, they are treated as tables, but there is no look up file.

Good example is the pitchers 'pitches', there is no dump that contains the actual pitchers, 'fastball, slider, etc.', but it is treated like a table.

Is this what you mean?
Comedian2004 is offline   Reply With Quote
Old 04-22-2007, 11:59 PM   #3 (permalink)
BMW
Minors (Triple A)
 
BMW's Avatar
 
Join Date: May 2003
Location: New Jersey
Posts: 258
Quote:
Originally Posted by Comedian2004 View Post
Some of the tables are not really tables, but are in a sort of way. What I mean is, they are treated as tables, but there is no look up file.

Good example is the pitchers 'pitches', there is no dump that contains the actual pitchers, 'fastball, slider, etc.', but it is treated like a table.

Is this what you mean?
I know what you're saying... There are some fields that are enumerations (i.e. they hold a value that corresponds to items on a list, but those items are not stored in a table), but I'm not certain what it has to do with indexing tables.

For the queries above, all that is required is that you take a full MySQL file dump and run the files against your MySQL database. From that point on, once they become a physical table in a MySQL database, I am considering that a table.

The code just creates some indexes on those tables, which will enable them to run a little faster when you are doing JOINs or other routine things.

Last edited by BMW : 04-23-2007 at 12:00 AM.
BMW is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 01:02 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 Out of the Park Developments