Question

PostgreSQL is interesting in that it supports several languages for writing stored procedures. Which one do you use, and why?

Was it helpful?

Solution

Skype uses PostgreSQL together with python, and they have improved PL/Python to it's current state so I would doubt that python support is far behind perl. They have written queuing/replication system on top of those bindings, after all :-)

Take a look: Wiki Skytools

From a quick look in documentation, python seems to have less documentation than perl bindings, but I would suggest to just stick with language you are most comfortable with.

OTHER TIPS

I have only really used PL/pgSQL, but that was because I needed a few stored procedures relatively fast and didn't want to add extra modules to the server.

Longer term, I would probably use PL/Perl or PL/Python, as I use perl for quick scripting and have been looking at python for a while now.

One thing I have found is that there is a lack of good documentation for that on the PostgreSQL site. The manuals were thorough as a reference, but did not work well as a tutorial to help show people how it should be done.

That, combined with a very good debugging environment, meant that my first experience of writing procedures involved looking at weird syntax errors for a long time.

If someone knows of a good site with tutorials etc for PostgreSQL programming, I would love to get a link to it.

I write pretty much everything in plpgsql, but I'm also a database guy first and foremost, so it generally suits me better than any other language. But there's plenty of things that it doesn't do very well, in which case another language such as plperl or plpython is a good bet. Of course, if speed is a serious concern, C is the way to go.

When I wrote my first trigger it was in Perl because that was the language used in the example I found but the last triggers I wrote where in Python because I'm more comfortable with that.

I think programmer comfort is my main reason to choose python but I think Perl is still better supported.

For anything really small/simple or that doesn't require a lot of string manipulation or logic, I use plpgsql, because it's fast. For more complex things, I use plperl, because I like it.

PL/Ruby because I use Ruby every day anyway.

I use PL/pgSQL for most everything, and if there is something it can't do I write functions in PL/Python (which rocks). You can also use PL/Java, PL/Perl, PL/PHP.

I would say Python is probably the best all around one because Python is on just about every linux system. Perl would be second with Python beating it because of the easier reading syntax.

I use PL/Perl because:

  • I like Perl
  • It's a dynamic language, which means that you can do some useful tricks easy, i.e. passing a column name to a trigger function and doing some actions with the value of this column in a trigger tuple.
  • It has a pretty good documentation

I would say Python is probably the best all around one because Python is on just about every linux system.Python beating it because of the easier reading syntax

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top