关于 Mysql中有个字段数据量很大,但是需要读取该字段的摘要?

WBOY
Release: 2016-06-06 20:27:42
Original
1194 people have browsed it

关于 Mysql表中有个字段数据量很大,但是需要读取该字段的摘要。
比如这个字段主要用来存文章,这个表的所有记录的这个字段都很长。

在查询的时候用select title,content from article的效率比select title from article 差太多。

之前的做法是直接读取content这个字段,然后用函数截取,作为文章摘要。

目前想到一个方法,就是存成两个字段,内容字段和内容摘要字段,但如果内容编辑的话,需要更新到内容摘要字段。

有什么比较好的方法提升效率?

回复内容:

关于 Mysql表中有个字段数据量很大,但是需要读取该字段的摘要。
比如这个字段主要用来存文章,这个表的所有记录的这个字段都很长。

在查询的时候用select title,content from article的效率比select title from article 差太多。

之前的做法是直接读取content这个字段,然后用函数截取,作为文章摘要。

目前想到一个方法,就是存成两个字段,内容字段和内容摘要字段,但如果内容编辑的话,需要更新到内容摘要字段。

有什么比较好的方法提升效率?

我觉得应该用redis等 cache 将字段摘要缓存住,每次增 删 改 摘要的时候,同步下缓存即可.这样放在cache里面不用查库了redis效率很高!!!

  1. 实际上你已经想到办法了,摘要独立存储就是个不错的办法

  2. 引入外部缓存,例如redis,memcache等

select title,content和单独select title对比
1.你的表是什么类型的
2.需要考虑传输的数据量 ,因为数据交互不仅仅是数据库干活 还有网卡

select title,LEFT(content) as description from article

其实你自己已经有了答案

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!