我想知道在plpgsql函數體和函數調用中添加LIMIT和OFFSET是否有區別。Postgresql優化問題
CREATE FUNCTION test()
RETURNS record AS
$body$
DECLARE
BEGIN
select * from producent order by id limit 5 offset 10;
END;
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER;
CREATE FUNCTION test1()
RETURNS record AS
$body$
DECLARE
BEGIN
select * from producent order by id;
END;
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER;
這將更快:
select * from test();
或
select * from test1() limit 5 offset 10;
如果它在功能之外,從開發人員的角度來看它更加靈活 – 2010-09-23 13:42:20