将去重逻辑从数据库剥离,交给代码执行环境,提高数据库生产效率

 

 

将去重逻辑从数据库剥离,交给代码执行环境,提高数据库生产效率

 

def get_produced_uid_l(produced_status, lim):
    q = 'SELECT uid FROM (SELECT uid,COUNT(1) AS c  FROM {} WHERE status={} GROUP BY uid) AS t WHERE t.c>{}'.format(
        db_tab, produced_status, lim)
    print(q)
    logging.info(q)
    try:
        # 将去重逻辑从数据库剥离,交给代码执行环境,提高数据库生产效率
        return [i[0] for i in set(mysql_fetch(mysql_key, q))]  # int
    except Exception as e:
        print(e)
        return False

  




posted @ 2018-05-18 09:24  papering  阅读(350)  评论(0编辑  收藏  举报