同样的查询在函数外运行得更快,但在函数中运行得慢了几百倍,当我删除where子句时,它在函数中运行得也更快,但并不比原始查询快。
RETURN QUERY (SELECT
t.tran_id, t.tran_date, t.value_date, t.statement_reference, t.debit, t.credit,t.office_id
FROM transactions.transactions_view t
WHERE t.tran_date BETWEEN from_::date AND to_::date
AND t.gl_account_id = gl_account_id_);
1条答案
按热度按时间yhxst69z1#
You should try with:
See RETURN QUERY vs RETURN QUERY EXECUTE and PostgreSQL: Documentation