Subject | Stored Proc vs View, which one has better performance? |
---|---|
Author | trskopo |
Post date | 2012-10-30T04:19:53Z |
Hi all,
I have a table, let say Tbl1, which structure something like this
id_cst int, id_gd int, qty int.
I want to select from that table, all records that has sum(qty) > 0 group by id_cst and id_gd.
I have 2 options to do that :
1) create a view with a ddl like this :
create view tmp (id_cst, id_gd, qty) as
select id_cst,id_gd,sum(qty) from Tbl1
group by id_cst,id_gd
then select that view with ddl : select * from tmp where qty > 0
2) create a stored procedure that returns all records which qty > 0
Between those options, with one has a better performance?
Thanks and regards,
Sugi.
I have a table, let say Tbl1, which structure something like this
id_cst int, id_gd int, qty int.
I want to select from that table, all records that has sum(qty) > 0 group by id_cst and id_gd.
I have 2 options to do that :
1) create a view with a ddl like this :
create view tmp (id_cst, id_gd, qty) as
select id_cst,id_gd,sum(qty) from Tbl1
group by id_cst,id_gd
then select that view with ddl : select * from tmp where qty > 0
2) create a stored procedure that returns all records which qty > 0
Between those options, with one has a better performance?
Thanks and regards,
Sugi.