最近在练习小说爬虫。
// mongoose Schema 结构
const ChapterSchema = new mongoose.Schema({
title: { type: String, required: true }, // 章节名称
href: { type: String, required: true }, // 章节地址
sort: { type: Number, required: true }, // 章节序号,取数据时排序用
belong_novel: { type: String, required: true }, // 所属小说
belong_author: { type: String, required: true }, // 所属作者
content: { type: String }, // 小说内容
});
小说内容用 String 类型定义的,sort 字段表示小说章节排序,如 "第一章 xxx" 的 sort 就是 1,依次类推。
抓了 2800 多章节小说,在取数据时根据 sort 进行排序,每次要花了4-5分钟才行。我现在很纳闷 3000 条不到的数据算大数据量吗??为啥取的这么慢,最终猜测是不是我用 String 定义字段接收导致的??问下大佬们是用什么类型接收长字符串的,或者怎么样能缩短查询时间。