Questions

What is the difference between and function and a stored procedure?

The word function and procedure is often mixed up. However, there is actually a difference: In a procedure, you can run more than just one transaction. It can therefore not be part of a SELECT statement and has to be executed using the CALL command. In contrast to that, a function has only limited transaction control and can be part of a SELECT, INSERT, UPDATE, or DELETE statement.

What is the difference between a trusted and an untrusted language?

Trusted languages limit the programmer's ability to perform system calls. They are therefore considered to be safe. Untrusted languages, however, can perform all kinds of operations and are therefore only available to superusers to ensure that no security leaks are possible.

Are functions in general good or bad?

This question is somewhat hard to answer. Nothing is only good or only bad. The same applies to functions. They can help you achieve your goal faster but sometimes it can be be a burden if used excessively. As with all things in life, functions should be used in a useful way.

Which server-side languages are available in PostgreSQL?

Traditionally, PostgreSQL has been very flexible when it comes to server-side functions. The core provides support for SQL, PL/pgSQL, PL/Perl, PL/TCL, and PL/Python. However, there are many more languages that can be installed from various sources that can be used for great benefit. The more popular ones are PL/V8 (JavaScript) and PL/R.

What is a trigger?

A trigger is a means to automatically execute a function when rows are changed. There are various types of triggers: ROW LEVEL triggers, which are fired for every row, STATEMENT LEVEL triggers, which are fired for a statement, and EVENT TRIGGERS, which can be fired for a DLL command.

Which languages can be used to write functions?

Basically functions can be written in SQL, PL/pgSQL, PL/Perl, PL/TCL and PL/Python. Addition languages can be added on demand if needed. It depends on your use case which language is best and it is highly encouraged to experiment.

Are functions generally good or generally bad?

This is hard to say. It really depends on what you are trying to achieve. In my personal opinion, moving algorithms close to where the data is, is a really good idea. However, some people might feel differently about this question in general. I think that "nothing fits all" so it makes sense to figure out what is best for you by looking at your situation and at what you are trying to achieve.

Which language is fastest?

That really depends on what you are trying to do. I think there is no overall answer to this question and most likely there will never be one. You have to check on a case by case basis.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset