1
leeoo 2017-07-07 14:22:14 +08:00
题主把测试代码贴出来看下。或者试试用 pg8000 对比下性能怎么样。
|
2
ballshapesdsd OP @leeoo
@profile def aaa(): for i in range(10000): sqlcmd='''select * from link_tbl where link_id=10360000000013''' cur.execute(sqlcmd) b=cur.fetchall() aaa() @profile def bbb(): sqlcmd=''' CREATE OR REPLACE FUNCTION bbb() RETURNS smallint LANGUAGE plpgsql volatile AS $$ DECLARE node_id bigint; i integer; BEGIN for i in 1..10000 loop select s_node into node_id from link_tbl where link_id=10360000000013; end loop; return 1; END; $$; select bbb(); ''' cur.execute(sqlcmd) conn_str.commit() bbb() @profile def ccc(): for i in range(10000): sqlcmd='''select 10360000000013;''' cur.execute(sqlcmd) b=cur.fetchall() ccc() |
3
ballshapesdsd OP 现在问题解决了,我把整个数据表加载到内存里,用字典存起来,这样查询快很多,不过内存用了 7,8 个 g。
|