Ticket #107 (closed defect: fixed)

Opened 14 years ago

Last modified 14 years ago

寻找丢失的数据——建商品全量索引时数据丢失的问题

Reported by: huangzhong Owned by: huangzhong
Priority: major Milestone: 2012年6.0版本
Component: 系统相关 Version: 6.0
Keywords: 索引,数据库迁移 Cc:
Due Date: 12/06/2012

Description

  • 现象

在测试商城搜索时发现产品页面上显示某种产品有多少个商家报价,但点进去看确发现没有这么多商家

  • 分析

在对建索引sql语句进行分析执行之后发现,数据库中确实是有这么多商家报价的,但为什么在索引中会少呢,难道是写索引的时候报错了,把建索引sql加上product_id条件,只写这个出问题的产品索引,发现一切正常。写索引的时候是按照10万数据来做分页的,难道是分页算法有误,测试了之后发现分页算法也没问题。最后发现是因为建索引sql语句没有指定order by,所以分页的时候是数据是不确定的。

  • 解决方案

对建索引sql加上指定order by字段

  • 延伸

对postgresql作分页的时候,最好是加上order by,不然出来的数据很可能不是你想要的

Change History

comment:1 Changed 14 years ago by huangzhong

  • Keywords 索引,数据库迁移 added

comment:2 Changed 14 years ago by chenchongqi

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.