【巨杉数据库Sequoiadb】【咨询】【数据操作】【聚集查询】使用OID作为分组字段并使用聚集查询该字段的count数

【问题描述】
如何使用OID作为分组字段并使用聚集查询该字段的count数?
记录类似如下:
{
“_id”:{
KaTeX parse error: Expected 'EOF', got '}' at position 36: …48af889cff" }̲, "ECM_BUSI_…oid”:“5c2c165cd08e8a48af889cfe”
},
“SYS_MIN_VERSION”:1,
“SYS_MAX_VERSION”:2147483647
}
记录使用FILE_OID字段进行聚集,FILE_OID是lob文件的oid字段,记录中该字段有重复非唯一。
【解决办法】
OID 即对象 ID 为一个12字节的BSON 数据类型,包括如下内容:
OID 说明具体可参考文档:http://doc.sequoiadb.com/cn/index-cat_id-1440658403-edition_id-302

  1. SDB shell 中按 OID 值做分组,使用 aggregate 做聚集查询,并计数:
    db.cs.cl.aggregate({KaTeX parse error: Expected '}', got 'EOF' at end of input: group:{OID:"OID", Total:{ c o u n t : " count:" OID"}}})
    aggregate 使用参考文档:http://doc.sequoiadb.com/cn/sequoiadb-cat_id-1432190825-edition_id-302
  2. 使用内置 SQL 语句:db.exec(“select count(OID) as Total from XXX group by OID”)
    group by 使用参考文档:http://doc.sequoiadb.com/cn/sequoiadb-cat_id-1432190963-edition_id-302
    【解决办法】
    OID 即对象 ID 为一个12字节的BSON 数据类型,包括如下内容:
    4 字节精确到秒的时间戳
    3 字节系统(物理机)标示
    2 字节进程 ID
    3 字节由随机数起始的序列号
    OID 说明具体可参考文档:http://doc.sequoiadb.com/cn/index-cat_id-1440658403-edition_id-302
  3. SDB shell 中按 OID 值做分组,使用 aggregate 做聚集查询,并计数:
    db.cs.cl.aggregate({KaTeX parse error: Expected '}', got 'EOF' at end of input: group:{OID:"OID", Total:{ c o u n t : " count:" OID"}}})
    aggregate 使用参考文档:http://doc.sequoiadb.com/cn/sequoiadb-cat_id-1432190825-edition_id-302
  4. 使用内置 SQL 语句:db.exec(“select count(OID) as Total from XXX group by OID”)
    group by 使用参考文档:http://doc.sequoiadb.com/cn/sequoiadb-cat_id-1432190963-edition_id-302

猜你喜欢

转载自blog.csdn.net/Kamani_msd/article/details/93718226