- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我尝试获取 75000 行并插入每个团队的统计数据时,我得到 503 服务不可用。当我限制为 10000 行时,它工作得很好,但看起来 75000 行太多了,无法加载?超时、上传和内存限制为 99999,这是 cloudways 服务器上的最大值。
首先
我从historymatches表中得到大约75000行,如下所示:
function select_tipgin_teams($season){
$select1 =
$this->db->select("HomeGoals as FTHG,AwayGoals as FTAG,HalfTimeHomeGoals as HTHG,
HalfTimeAwayGoals as HTAG,HomeTeam,AwayTeam,HomeTeamID,AwayTeamID,League,LeagueID")
->where('Season',$season)
->order_by('Date','desc')
->get('historicmatches');
return $select1;
}
我想从比赛中获取每支球队并为每支球队插入数据。脚本太长,无法粘贴到这里,它不是太重要。
最后我使用此查询插入数据,userstats 表有超过 200 列...
function insert_userstats($insert){
$query =
"INSERT INTO `zzazfhvsnt`.`userstats`
(`teamid`,`teamname`,`league`,`leagueid`,`leaguecode`,`season`,`played`,`played_home`,`played_away`,`win_home`,`draw_home`,`loss_home`,
`win_away`,`draw_away`,`loss_away`,`odds_home_win`,`odds_home_draw`,`odds_home_loss`,
`odds_away_win`,`odds_away_draw`,`odds_away_loss`,`odds_avg_win`,`goals_scored`,`goals_scored_home`,
`goals_scored_away`,`first_half_goals`,`second_half_goals`,`goals_conceded`,`goals_conceded_home`,
`goals_conceded_away`,`first_half_conceded`,`second_half_conceded`,`both_score_yes`,`both_score_no`,
`both_score_home_yes`,`both_score_home_no`,`both_score_away_yes`,`both_score_away_no`,
`both_score_1st_yes`,`both_score_1st_no`,`both_score_2nd_yes`,`both_score_2nd_no`,
over05,over15,over25,over35,over45,under05,under15,under25,under35,under45,over05_home,over15_home,
over25_home,over35_home,over45_home,under05_home,under15_home,under25_home,under35_home,under45_home,
over05_away,over15_away,over25_away,over35_away,over45_away,under05_away,under15_away,under25_away,
under35_away,under45_away,over05_1st,over15_1st,over25_1st,over35_1st,over45_1st,
under05_1st,under15_1st,under25_1st,under35_1st,under45_1st,over05_2nd,over15_2nd,over25_2nd,
over35_2nd,over45_2nd,under05_2nd,under15_2nd,under25_2nd,under35_2nd,under45_2nd,
`halffull_hh`,`halffull_hd`,`halffull_ha`,`halffull_dh`,`halffull_dd`,`halffull_da`,`halffull_ah`,
`halffull_ad`,`halffull_aa`, `halffull_home_hh`,`halffull_home_hd`,`halffull_home_ha`,
`halffull_home_dh`,`halffull_home_dd`,`halffull_home_da`,`halffull_home_ah`,`halffull_home_ad`,
`halffull_home_aa`,`halffull_away_hh`,`halffull_away_hd`,`halffull_away_ha`,`halffull_away_dh`,
`halffull_away_dd`,`halffull_away_da`,`halffull_away_ah`,`halffull_away_ad`,`halffull_away_aa`,
halfmost_first,halfmost_second,halfmost_equal,halfmost_home_first,halfmost_home_second,
halfmost_home_equal,halfmost_away_first,halfmost_away_second,halfmost_away_equal,
`win_both_halves_home_yes`,`win_both_halves_home_no`,`win_both_halves_away_yes`,
`win_both_halves_away_no`,`score_both_halves_home_yes`,`score_both_halves_home_no`,
`score_both_halves_away_yes`,`score_both_halves_away_no`,`halftime_home_win_1h`,
`halftime_home_win_2h`,`halftime_home_win_home_1h`,`halftime_home_win_home_2h`,
`halftime_home_win_away_1h`,`halftime_home_win_away_2h`,`halftime_draw_1h`,
`halftime_draw_2h`,`halftime_draw_home_1h`,`halftime_draw_home_2h`,`halftime_draw_away_1h`,
`halftime_draw_away_2h`,`halftime_away_win_1h`,`halftime_away_win_2h`,`halftime_away_win_home_1h`,
`halftime_away_win_home_2h`,`halftime_away_win_away_1h`,`halftime_away_win_away_2h`,
`wins_to_nil_yes`,`wins_to_nil_home_yes`,`wins_to_nil_away_yes`,`bts_over25`,`bts_over25_home`,
`bts_over25_away`,corner_for,corner_against,corner_home_for,corner_home_against,corner_away_for,
corner_away_against,corner_min_for,corner_max_for,corner_min_against,corner_max_against,
corner_min_home_for,corner_max_home_for,corner_min_home_against,corner_max_home_against,
corner_min_away_for,corner_max_away_for,corner_min_away_against,corner_max_away_against,
shot_for,shot_against,shot_home_for,shot_home_against,shot_away_for,shot_away_against,shot_min_for,
shot_max_for,shot_min_against,shot_max_against,shot_min_home_for,shot_max_home_for,
shot_min_home_against,shot_max_home_against,shot_min_away_for,shot_max_away_for,
shot_min_away_against,shot_max_away_against,target_for,target_against,target_home_for,
target_home_against,target_away_for,target_away_against,target_min_for,target_max_for,
target_min_against,target_max_against,target_min_home_for,target_max_home_for,
target_min_home_against,target_max_home_against,target_min_away_for,target_max_away_for,
target_min_away_against,target_max_away_against,
fouls_for,fouls_against,fouls_home_for,
fouls_home_against,fouls_away_for,fouls_away_against,fouls_min_for,fouls_max_for,fouls_min_against,
fouls_max_against,fouls_min_home_for,fouls_max_home_for,fouls_min_home_against,fouls_max_home_against,
fouls_min_away_for,fouls_max_away_for,fouls_min_away_against,fouls_max_away_against,
yellow_team,yellow_opponent,yellow_home_team,yellow_home_opponent,yellow_away_team,
yellow_away_opponent,yellow_min_team,yellow_max_team,yellow_min_opponent,yellow_max_opponent,
yellow_min_home_team,yellow_max_home_team,yellow_min_home_opponent,yellow_max_home_opponent,
yellow_min_away_team,yellow_max_away_team,yellow_min_away_opponent,yellow_max_away_opponent,
red_team,red_opponent,red_home_team,red_home_opponent,red_away_team,red_away_opponent,exact_score,
exact_score_home,exact_score_away,exact_score_1st,exact_score_2nd,`title_overall`,`title_home`,
`title_away`,`top3_overall`,`top3_home`,`top3_away`, `mid_overall`,`mid_home`,`mid_away`,
`bott3_overall`,`bott3_home`,`bott3_away`,`rel_overall`,`rel_home`,`rel_away`,`source`
)
VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
ON DUPLICATE KEY UPDATE
`teamid` = ?,`teamname` = ?,`league` = ?,`leagueid` = ?,`leaguecode` = ?,`season` = ?,
`played` = `played` + ?,`played_home` = `played_home` + ?,`played_away` = `played_away` + ?,
`win_home` = `win_home` + ?,`draw_home` = `draw_home` + ?,`loss_home` = `loss_home` + ?,
`win_away` = `win_away` + ?,`draw_away` = `draw_away` + ?,`loss_away` = `loss_away` + ?,
`odds_home_win` = `odds_home_win` + ?,`odds_home_draw` = `odds_home_draw` + ?,
`odds_home_loss` = `odds_home_loss` + ?,`odds_away_win` = `odds_away_win` + ?,
`odds_away_draw` = `odds_away_draw` + ?,`odds_away_loss` = `odds_away_loss` + ?,
`odds_avg_win` = `odds_avg_win` + ?,`goals_scored` = `goals_scored` + ?,
`goals_scored_home` = `goals_scored_home` + ?,`goals_scored_away` = `goals_scored_away` + ?,
`first_half_goals` = `first_half_goals` + ?,`second_half_goals` = `second_half_goals` + ?,
`goals_conceded` = `goals_conceded` + ?,`goals_conceded_home` = `goals_conceded_home` + ?,
`goals_conceded_away` = `goals_conceded_away` + ?,`first_half_conceded` = `first_half_conceded` + ?,
`second_half_conceded` = `second_half_conceded` + ?,`both_score_yes` = `both_score_yes` + ?,
`both_score_no` = `both_score_no` + ?,`both_score_home_yes` = `both_score_home_yes` + ?,
`both_score_home_no` = `both_score_home_no` + ?,`both_score_away_yes` = `both_score_away_yes` + ?,
`both_score_away_no` = `both_score_away_no` + ?,`both_score_1st_yes` = `both_score_1st_yes` + ?,
`both_score_1st_no` = `both_score_1st_no` + ?,`both_score_2nd_yes` = `both_score_2nd_yes` + ?,
`both_score_2nd_no` = `both_score_2nd_no` + ?,over05 = over05 + ?,over15 = over15 + ?,
over25 = over25 + ?,over35 = over35 + ?,over45 = over45 + ?,under05 = under05 + ?,
under15 = under15 + ?,under25 = under25 + ?,under35 = under35 + ?,under45 = under45 + ?,
over05_home = over05_home + ?,over15_home = over15_home + ?,over25_home = over25_home + ?,
over35_home = over35_home + ?,over45_home = over45_home + ?,under05_home = under05_home + ?,
under15_home = under15_home + ?,under25_home = under25_home + ?,under35_home = under35_home + ?,
under45_home = under45_home + ?,over05_away = over05_away + ?,over15_away = over15_away + ?,
over25_away = over25_away + ?,over35_away = over35_away + ?,over45_away = over45_away + ?,
under05_away = under05_away + ?,under15_away = under15_away + ?,under25_away = under25_away + ?,
under35_away = under35_away + ?,under45_away = under45_away + ?,over05_1st = over05_1st + ?,
over15_1st = over15_1st + ?,over25_1st = over25_1st + ?,over35_1st = over35_1st + ?,
over45_1st = over45_1st + ?,under05_1st = under05_1st + ?,under15_1st = under15_1st + ?,
under25_1st = under25_1st + ?,under35_1st = under35_1st + ?,under45_1st = under45_1st + ?,
over05_2nd = over05_2nd + ?,over15_2nd = over15_2nd + ?,over25_2nd = over25_2nd + ?,
over35_2nd = over35_2nd + ?,over45_2nd = over45_2nd + ?,under05_2nd = under05_2nd + ?,
under15_2nd = under15_2nd + ?,under25_2nd = under25_2nd + ?,under35_2nd = under35_2nd + ?,
under45_2nd = under45_2nd + ?,
`halffull_hh` = `halffull_hh` + ?,`halffull_hd` = `halffull_hd` + ?,`halffull_ha` = `halffull_ha` + ?
,`halffull_dh` = `halffull_dh` + ?,`halffull_dd` = `halffull_dd` + ?,`halffull_da` = `halffull_da` + ?
,`halffull_ah` = `halffull_ah` + ?,`halffull_ad` = `halffull_ad` + ?,`halffull_aa` = `halffull_aa` + ?,
`halffull_home_hh` = `halffull_home_hh` + ?,`halffull_home_hd` = `halffull_home_hd` + ?,
`halffull_home_ha` = `halffull_home_ha` + ?,
`halffull_home_dh` = `halffull_home_dh` + ?,`halffull_home_dd` = `halffull_home_dd` + ?,
`halffull_home_da` = `halffull_home_da` + ?,`halffull_home_ah` = `halffull_home_ah` + ?,
`halffull_home_ad` = `halffull_home_ad` + ?,
`halffull_home_aa` = `halffull_home_aa` + ?,`halffull_away_hh` = `halffull_away_hh` + ?,
`halffull_away_hd` = `halffull_away_hd` + ?,`halffull_away_ha` = `halffull_away_ha` + ?,
`halffull_away_dh` = `halffull_away_dh` + ?,
`halffull_away_dd` = `halffull_away_dd` + ?,`halffull_away_da` = `halffull_away_da` + ?,
`halffull_away_ah` = `halffull_away_ah` + ?,`halffull_away_ad` = `halffull_away_ad` + ?,
`halffull_away_aa` = `halffull_away_aa` + ?,halfmost_first = halfmost_first + ?,
halfmost_second = halfmost_second + ?,halfmost_equal = halfmost_equal + ?,
halfmost_home_first = halfmost_home_first + ?,halfmost_home_second = halfmost_home_second + ?,
halfmost_home_equal = halfmost_home_equal + ?,halfmost_away_first = halfmost_away_first + ?,
halfmost_away_second = halfmost_away_second + ?,halfmost_away_equal = halfmost_away_equal + ?,
`win_both_halves_home_yes` = win_both_halves_home_yes + ?,
`win_both_halves_home_no` = win_both_halves_home_no + ?,
`win_both_halves_away_yes` = win_both_halves_away_yes + ?,
`win_both_halves_away_no` = win_both_halves_away_no + ?,
`score_both_halves_home_yes` = score_both_halves_home_yes + ?,
`score_both_halves_home_no` = score_both_halves_home_no + ?,
`score_both_halves_away_yes` = score_both_halves_away_yes + ?,
`score_both_halves_away_no` = score_both_halves_away_no + ?,
`halftime_home_win_1h` = halftime_home_win_1h + ?,`halftime_home_win_2h` = halftime_home_win_2h + ?,
`halftime_home_win_home_1h` = halftime_home_win_home_1h + ?,
`halftime_home_win_home_2h` = halftime_home_win_home_2h + ?,
`halftime_home_win_away_1h` = halftime_home_win_away_1h + ?,
`halftime_home_win_away_2h` = halftime_home_win_away_2h + ?,`halftime_draw_1h` = halftime_draw_1h + ?,
`halftime_draw_2h` = halftime_draw_2h + ?,`halftime_draw_home_1h` = halftime_draw_home_1h + ?,
`halftime_draw_home_2h` = halftime_draw_home_2h + ?,`halftime_draw_away_1h` = halftime_draw_away_1h + ?,
`halftime_draw_away_2h` = halftime_draw_away_2h + ?,`halftime_away_win_1h` = halftime_away_win_1h + ?,
`halftime_away_win_2h` = halftime_away_win_2h + ?,
`halftime_away_win_home_1h` = halftime_away_win_home_1h + ?,
`halftime_away_win_home_2h` = halftime_away_win_home_2h + ?,
`halftime_away_win_away_1h` = halftime_away_win_away_1h + ?,
`halftime_away_win_away_2h` = halftime_away_win_away_2h + ?,
`wins_to_nil_yes` = wins_to_nil_yes + ?,`wins_to_nil_home_yes` = wins_to_nil_home_yes + ?,
`wins_to_nil_away_yes` = wins_to_nil_away_yes + ?,`bts_over25` = bts_over25 + ?,
`bts_over25_home` = bts_over25_home + ?,`bts_over25_away` = bts_over25_away + ?,
corner_for = corner_for + ?,corner_against = corner_against + ?,corner_home_for = corner_home_for + ?,
corner_home_against = corner_home_against + ?,corner_away_for = corner_away_for + ?,
corner_away_against = corner_away_against + ?,corner_min_for = ?,corner_max_for = ?,corner_min_against = ?,
corner_max_against = ?,corner_min_home_for = ?,corner_max_home_for = ?,corner_min_home_against = ?,
corner_max_home_against = ?,corner_min_away_for = ?,corner_max_away_for = ?,
corner_min_away_against = ?,corner_max_away_against = ?,
shot_for=shot_for+?,shot_against=shot_against+?,shot_home_for=shot_home_for+?,
shot_home_against=shot_home_against+?,shot_away_for=shot_away_for+?,
shot_away_against=shot_away_against+?,
shot_min_for=?,shot_max_for=?,shot_min_against=?,shot_max_against=?,shot_min_home_for=?,
shot_max_home_for=?,shot_min_home_against=?,shot_max_home_against=?,shot_min_away_for=?,
shot_max_away_for=?,shot_min_away_against=?,shot_max_away_against=?,target_for=target_for+?,
target_against=target_against+?,target_home_for=target_home_for+?,
target_home_against=target_home_against+?,target_away_for=target_away_for+?,
target_away_against=target_away_against+?,target_min_for=?,target_max_for=?,
target_min_against=?,target_max_against=?,target_min_home_for=?,target_max_home_for=?,
target_min_home_against=?,target_max_home_against=?,target_min_away_for=?,target_max_away_for=?,
target_min_away_against=?,target_max_away_against=?,
fouls_for = fouls_for + ?,fouls_against = fouls_against + ?,fouls_home_for = fouls_home_for + ?,
fouls_home_against = fouls_home_against + ?,fouls_away_for = fouls_away_for + ?,
fouls_away_against = fouls_away_against + ?,fouls_min_for = ?,fouls_max_for = ?,fouls_min_against=?,
fouls_max_against=?,fouls_min_home_for=?,fouls_max_home_for=?,fouls_min_home_against=?,
fouls_max_home_against=?,fouls_min_away_for=?,fouls_max_away_for=?,fouls_min_away_against=?,
fouls_max_away_against=?,
yellow_team = yellow_team + ?,yellow_opponent = yellow_opponent + ?,
yellow_home_team = yellow_home_team + ?,yellow_home_opponent = yellow_home_opponent + ?,
yellow_away_team = yellow_away_team + ?,yellow_away_opponent = yellow_away_opponent + ?,
yellow_min_team = ?,yellow_max_team = ?,yellow_min_opponent = ?,yellow_max_opponent = ?,
yellow_min_home_team = ?,yellow_max_home_team = ?,yellow_min_home_opponent = ?,
yellow_max_home_opponent = ?,yellow_min_away_team = ?,yellow_max_away_team = ?,
yellow_min_away_opponent = ?,yellow_max_away_opponent = ?,
red_team = red_team + ?,red_opponent = red_opponent + ?,red_home_team = red_home_team + ?,
red_home_opponent = red_home_opponent + ?,red_away_team = red_away_team + ?,
red_away_opponent = red_away_opponent + ?,exact_score = ?,exact_score_home = ?,
exact_score_away = ?,exact_score_1st = ?,exact_score_2nd = ?,`title_overall`=?,`title_home`=?,
`title_away`=?,`top3_overall`=?,`top3_home`=?,`top3_away`=?,`mid_overall`=?,`mid_home`=?,`mid_away`=?,
`bott3_overall`=?,`bott3_home`=?,`bott3_away`=?,`rel_overall`=?,`rel_home`=?,`rel_away`=?,`source`=?
;";
$this->db->query($query,$insert);
}
我能做什么?
最佳答案
使用循环,每次迭代仅执行 5K 到 10K 查询。几年前,我遇到了类似的问题,当时我必须从一个表到另一个表选择/插入数百万个条目。使用循环解决了它。
关于php - 读取和插入大表时出现 503 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38280394/
我遇到以下问题。我想读取一个包含数百万行和数百列的大型 csv。我想向下转换列的数据类型。我的方法是读取 csv,然后使用 pd.to_numeric() 对其进行向下转换。我不知道列数及其类型。在读
目前,我从 SQL server (2008) 数据库获取数据。 cyurrent的方法是使用DataTable,然后将其传递并使用。 if (parameters != null)
我有以下问题。我有一个巨大的 csv 文件,想用多处理加载它。对于一个包含 500000 行和 130 列不同数据类型的示例文件,Pandas 需要 19 秒。我试过 dask 因为我想多处理阅读。但
是否有关于用于序列化各种 MFC 数据结构的二进制格式的明确文档?我已经能够在十六进制编辑器中查看我自己的一些类,并使用 Java 的 ByteBuffer 类读取它们(使用自动字节顺序转换等)。 但
我正在使用 Selenium 进行测试,我们用 HTML 文件编写测试用例,并用它们制作测试套件,我们的要求是编写足够健壮的测试用例,以根据测试环境改变自身。 为此,我不希望在 HTML 脚本本身中包
我需要一个 JavaScript 代码来读取存储为 .txt 文件的字典(或者也可以保存为任何其他类型的文件。它也可以在线获得)并将其内容存储在一个变量中。我不能找到一种让 JavaScript 像
我正在尝试遍历包含 SSH 登录和其他日志的日志文本文件。 程序正在返回 SSH 登录的总数。 我的解决方案确实有效,但似乎有点慢(在 200mo 文件上大约需要 3.5 秒)。我想知道是否有任何方法
我正在将大量数据从一个电子表格复制到工作簿中的其他 160 个电子表格。目前,Excel (2013) 遇到错误,因为它没有足够的资源来完成操作。 我的目标是将工作表 4 中 V13:XI1150 范
我正在尝试读取一个有 1147 行的文本文件。下面的代码仅读取第 1050-1147 行。我的目标是读取整个文件并提取位于不同行的特定值以在脚本中使用。一个示例是包含“BlockList: 2”的行中
我正在为游戏编写解释器。用户将其移动输入解释器,程序执行该移动。 现在我想为每个决定实现一个时间限制。玩家不应该能够思考超过 30 秒来写一个移动并按下回车。 call_with_time_limit
以this file例如,我正在尝试读取 data.frame 中的数据。来自 the doc (pdf 文件,表 1),它遵循一些 fortran 约定。我尝试了以下但收效甚微: dir 0' 将
我正在使用 R 阅读 Outlook 附件。我的引用在这里:Download attachment from an outlook email using R 这是我的电子邮件的截图: 这每天都会发送
我不会从表格中读取行来将主题放在列表中 php脚本 $url_obj='http://'.$host.':8069/xmlrpc/object'; $sock=new xmlrpc_client($u
我有一个这样的 csv 文件: id,name,value 1,peter,5 2,peter\,paul,3 我如何读取此文件并告诉 R "\," 不表示新列,仅表示 ","。 我必须添加该文件
我正在尝试读取 ~/Library/Preferences/com.apple.mail.plist (在 Snow Leopard 上)以获取电子邮件地址和其他信息以进入“关于”对话框。我使用以下代
This question already has answers here: How do I use floating-point division in bash? (19个回答) 5个月前关闭
本练习的目标是读取输入文件并将其存储到表中,然后验证输入中的某些字段并输出任何错误记录。我需要读取并存储每个策略组,以便表中一次仅存储 5 条记录,而不是整个文件。 所以我需要读取一个包含 5 条记录
据我了解,LWT 插入始终以 SERIAL 一致性级别完成。如果为 true,这是否意味着读取作为 LWT 插入的行可以安全地以 ANY 的一致性级别读取? 换句话说,我假设 LWT 插入是完全一致的
我看到很多很多通过java脚本读取cookie的函数,但我只想在变量中使用它一次,我是JS新手。 这是我的代码 var TheNumber = (Math.random() + '') * 10000
我正在使用 asp.net 和 C#。我在服务器上部署了一个应用程序[已发布],现在我想查看该网站的代码,据我所知,我可以阅读程序集来查看代码。 请告诉我如何实现它。 提前致谢。 最佳答案 您可以使用
我是一名优秀的程序员,十分优秀!