sqlite - Codeiginter 4 批量插入
问题描述
我正在使用 CI4 创建一个应用程序来读取包含超过 100K 记录的系列播放列表。
问题是它需要很多时间并且即使在添加后也会耗尽内存:
ini_set('memory_limit', '1024M');
ini_set('max_execution_time', -1);
好的,我可以增加 memory_limit,但仍然需要很多时间。
我使用以下方法插入数据库:
$this->db->transStart();
$seriesTable = $this->db->table('tbl_series');
$seriesTable->emptyTable();
$seriesTable->insertBatch($series);
$this->db->transComplete();
并且$series
数组元素(情节)如下:
$epidose = array(
'clm_series_name' => $station['author'],
'clm_series_media_url' => $station['media_url'],
'clm_series_group' => $station['group'],
'clm_series_square' => $station['thumb_square'],
'clm_series_type' => $station['type'],
'clm_series_season' => $station['season'],
'clm_series_episode' => $station['episode']
);
我想就如何减少执行时间提出建议。使用事务没有帮助。
有什么建议么?
解决方案
推荐阅读
- google-apps-script - 在基于应用程序脚本的邮件合并中附加多个文件(动态和静态)
- c++ - 将原始指针与其拥有的 shared_ptr 一起缓存以获得更好的访问性能是一个好主意吗?
- flutter - 在 null 上调用了 getter 'documents'
- r - Rmarkdown 无法识别 kable_styling 命令中的内联
- python - HERE 请求如何为 params 中的键分配多个值
- node.js - 有没有办法忽略 Node.JS tls 中的自定义 CA 公用名?
- r - R - 有效地将列表列表的所有元素保存为 data.frame
- ruby-on-rails - 如何让活动作业永远重试所有作业?
- laravel - Laravel 建模系统
- r - 如何在 xts 图中标记和更改线条的颜色