时间:2021-07-01 10:21:17 帮助过:32人阅读
...
BEGIN
FOR i IN 1..num LOOP
SELECT func_process.sql() INTO counts;
if counts = 0 then return ‘mac地址已使用完‘;
end if;
end LOOP;
...
12 1...
2BEGIN
3
4FOR i IN 1..num LOOP
5
6 SELECT func_process.sql() INTO counts;
7
8 if counts = 0 then return ‘mac地址已使用完‘;
9 end if;
10
11end LOOP;
12...
select mac from macInfo where state = 0 limit 1;
1 1select mac from macInfo where state = 0 limit 1;
b)、调用func_uuid.sql,得到uuid【该方法通过plpythonu语言编写,生成UUID】>> select "state", "count"("state") from macinfo GROUP BY state;
>>
state count
1 641153
0 15000
5 1>> select "state", "count"("state") from macinfo GROUP BY state;
2>>
3state count
41 641153
50 15000
3、因此为state加上索引。CREATE INDEX "idx_macinfo_state" ON "usr"."macinfo" USING BTREE ("state");
1 1CREATE INDEX "idx_macinfo_state" ON "usr"."macinfo" USING BTREE ("state");
4、再次执行,发现速度还是很慢,几乎没有改变。create table usr.macinfo_copy as select * from usr.macinfo;
DELETE FROM usr.macinfo where "state" <> 0;
1 1create table usr.macinfo_copy as select * from usr.macinfo;
2DELETE FROM usr.macinfo where "state" <> 0;
6、再次执行,本次执行了1000条,发现耗时680s,换算成10000条也就是 10分钟多点。相比快了一倍,但是和最开始比还是慢了5倍。因此该方法还是不行记一次postgresql数据库函数执行问题
标签:因此 shell 引导 import sele class mil 语句 执行