Pergunta

I would like to know what are benefits and what are drawbacks of SQL stored procedures and procedures written on some common programming language, more precisely, which method is preferred in which situations.

Foi útil?

Solução

Stored procedures have the advantage of running on the server, whereas most common programming languages run on a client machine, or a separate server, incurring a network overhead. But work at a more abstract level than programming languages.

This means the stored procedure is good at handling a large amounts data using set based operations on the server. Programming languages are generally better if you need to do some heavy calculations.

Finding your prime customers from a large set of data, use a stored procedure.

Finding some large prime numbers, use common programming language. (other than SQL!)

Outras dicas

Generally speaking, it could be an advantage to write as much code as possible into the common programming language (PHP, Python, whatever), as all that code won't have to be adapted if you decide to change your DBMS.

Still generally, you will certainly want that your applications work with many DBMS, than maintaining your apps in several languages simultaneously :)

In general, you could say that stored procedures are faster, because they are closer to the data(base), but they lack the sophisticated possibilities of real programming languages.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top