Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
Facebook
Downloads
Home
>
mailing lists
[BUGS] Fwd: Problems about FUNCTIONS - Mailing list pgsql-bugs
From
Sistema Ágile
Subject
[BUGS] Fwd: Problems about FUNCTIONS
Date
December 13, 2016
22:35:20
Msg-id
CADt=wv24cdaOG9v4FRLPhTeYa9KdQd8YeLb+tngZs780HFgNXA@mail.gmail.com
Whole thread
Raw
In response to
[BUGS] Problems about FUNCTIONS
(Análise Sistema Ágile <analise@sistemaagile.com.br>)
List
pgsql-bugs
Tree view
Hi, I'm with problems about functions.
When I execute a select with Function is very slow, and when I execute repeating the code of the existing function inside my SQL is faster.
I need to centralize my code, because of that I'm using functions, but is very very slow..
Please how can I use Function and become faster? I need to centralize the SQL.
See my examples...
MY FUNCTION:
CREATE OR REPLACE FUNCTION sp_valor (
parcodfilial numeric,
parcodpedido numeric,
parcoditem numeric,
parcodproduto numeric,
partipodif char
)
RETURNS numeric AS
$body$
DECLARE
VALOR NUMERIC;
BEGIN
SELECT COALESCE(SUM(A.VLRUNIT),0) INTO VALOR
FROM FAT0013 A
WHERE A.CODFILIAL = PARCODFILIAL
AND A.CODPEDIDO = PARCODPEDIDO
AND A.CODITEM = PARCODITEM
AND A.CODPRODUTO = PARCODPRODUTO
AND A.TIPODIF = PARTIPODIF;
RETURN VALOR;
END;
$body$
LANGUAGE 'plpgsql'
VOLATILE
;
SQL FAST (00:17):
SELECT A.CODFILIAL,
A.CODPEDIDO,
(SELECT COALESCE(SUM(X.VLRUNIT),0) VALOR
FROM FAT0013 X
WHERE X.CODFILIAL = A.CODFILIAL
AND X.CODPEDIDO = A.CODPEDIDO
AND X.CODITEM = A.CODITEM
AND X.CODPRODUTO = A.CODPRODUTO
AND X.TIPODIF = 'A')
FROM FAT0002 A
SQL SLOW (04:54):
SELECT A.CODFILIAL,
A.CODPEDIDO,
SP_VALOR(A.CODFILIAL, A.CODPEDIDO, A.CODITEM, A.CODPRODUTO, 'A')
FROM FAT0002 A
Thanks.
--
Ágile Sistemas - (15) 3282-6925
www.sistemaagile.com.br
pgsql-bugs
by date:
Previous
From:
Análise Sistema Ágile
Date:
13 December 2016, 22:32:16
Subject:
[BUGS] Problems about FUNCTIONS
Next
From:
syspegasus@gmail.com
Date:
13 December 2016, 22:42:35
Subject:
[BUGS] BUG #14464: Problems about FUNCTIONS
Есть вопросы? Напишите нам!
Соглашаюсь с условиями обработки персональных данных
I confirm that I have read and accepted PostgresPro’s
Privacy Policy
.
I agree to get Postgres Pro discount offers and other marketing communications.
✖
×
×
Everywhere
Documentation
Mailing list
List:
all lists
pgsql-general
pgsql-hackers
buildfarm-members
pgadmin-hackers
pgadmin-support
pgsql-admin
pgsql-advocacy
pgsql-announce
pgsql-benchmarks
pgsql-bugs
pgsql-chat
pgsql-cluster-hackers
pgsql-committers
pgsql-cygwin
pgsql-docs
pgsql-hackers-pitr
pgsql-hackers-win32
pgsql-interfaces
pgsql-jdbc
pgsql-jobs
pgsql-novice
pgsql-odbc
pgsql-patches
pgsql-performance
pgsql-php
pgsql-pkg-debian
pgsql-pkg-yum
pgsql-ports
pgsql-rrreviewers
pgsql-ru-general
pgsql-sql
pgsql-students
pgsql-testers
pgsql-translators
pgsql-www
psycopg
Period
anytime
within last day
within last week
within last month
within last 6 months
within last year
Sort by
date
reverse date
rank
Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
By continuing to browse this website, you agree to the use of cookies. Go to
Privacy Policy
.
I accept cookies