Thread: plperl vs plpgsql
Hi, i am thinking about swiching to plperl as it seems to me much more flexible and easier to create functions. what is the recommended PL for postgres? or which one is most widely used / most popular? is there a performance difference between plpgsql and plperl ? porting to other systems is not a real issue as all my servers have perl installed. Thanks for any advice Alex
After takin a swig o' Arrakan spice grog, alex@meerkatsoft.com (Alex) belched out: > i am thinking about swiching to plperl as it seems to me much more > flexible and easier to create functions. > > what is the recommended PL for postgres? or which one is most widely > used / most popular? > is there a performance difference between plpgsql and plperl ? If what you're trying to do is "munge text," pl/perl will be a whole lot more suitable than pl/pgsql because it has a rich set of text mungeing tools and string functions which pl/pgsql lacks. If you intend to do a lot of work involving reading unmunged tuples from this table and that, pl/pgsql provides a much more natural syntax, and will probably be a bit faster as the query processor may even be able to expand some of the actions, rather than needing to treat Perl code as an "opaque blob." I would definitely be inclined to use the more natural language for the given task... -- wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','acm.org'). http://linuxdatabases.info/info/internet.html "If you want to talk with some experts about something, go to the bar where they hang out, buy a round of beers, and they'll surely talk your ear off, leaving you wiser than before. If you, a stranger, show up at the bar, walk up to the table, and ask them to fax you a position paper, they'll tell you to call their office in the morning and ask for a rate sheet." -- Miguel Cruz
Is there a performance difference between the two? which of the PL is most widely used. One problem i have with the plpgsql is that the quoting is really a pain. Christopher Browne wrote: >After takin a swig o' Arrakan spice grog, alex@meerkatsoft.com (Alex) belched out: > > >>i am thinking about swiching to plperl as it seems to me much more >>flexible and easier to create functions. >> >>what is the recommended PL for postgres? or which one is most widely >>used / most popular? >>is there a performance difference between plpgsql and plperl ? >> >> > >If what you're trying to do is "munge text," pl/perl will be a whole >lot more suitable than pl/pgsql because it has a rich set of text >mungeing tools and string functions which pl/pgsql lacks. > >If you intend to do a lot of work involving reading unmunged tuples >from this table and that, pl/pgsql provides a much more natural >syntax, and will probably be a bit faster as the query processor may >even be able to expand some of the actions, rather than needing to >treat Perl code as an "opaque blob." > >I would definitely be inclined to use the more natural language for >the given task... > >
On 2005-04-17 14:56, Alex wrote: > Is there a performance difference between the two? As Christopher already pointed out, it depends on what you want to do. If you're doing some complex string processing, it will be easier (and in some cases) faster to do in plperl, if you're mainly dealing with sets, plpgsql will be better suited. > which of the PL is most widely used. plpgsql. > One problem i have with the plpgsql > is that the quoting is really a pain. In current versions of PostgreSQL you can use $$ quoting, which should make your life easier: http://www.postgresql.org/docs/8.0/static/plpgsql-structure.html http://www.postgresql.org/docs/8.0/static/plperl.html HTH, stefan
On Sun, 17 Apr 2005, Alex wrote: > Is there a performance difference between the two? Hello, It depends on what you are using it for. My experience is that for some reason plPGSQL is faster when looping but other than that they should be very similar. > which of the PL is most widely used. One problem i have with the plpgsql is > that the quoting is really a pain. plpgsql but I believe that will change in a short period of time. Sincerely, Joshua D. Drake -- Command Prompt, Inc., Your PostgreSQL solutions company. 503-667-4564 Custom programming, 24x7 support, managed services, and hosting Open Source Authors: plPHP, pgManage, Co-Authors: plPerlNG Reliable replication, Mammoth Replicator - http://www.commandprompt.com/
After a long battle with technology, alex@meerkatsoft.com (Alex), an earthling, wrote: > Christopher Browne wrote: >>After takin a swig o' Arrakan spice grog, alex@meerkatsoft.com (Alex) belched out: >>>i am thinking about swiching to plperl as it seems to me much more >>>flexible and easier to create functions. >>> >>>what is the recommended PL for postgres? or which one is most widely >>>used / most popular? >>>is there a performance difference between plpgsql and plperl ? >>> >>> >> >>If what you're trying to do is "munge text," pl/perl will be a whole >>lot more suitable than pl/pgsql because it has a rich set of text >>mungeing tools and string functions which pl/pgsql lacks. >> >>If you intend to do a lot of work involving reading unmunged tuples >>from this table and that, pl/pgsql provides a much more natural >>syntax, and will probably be a bit faster as the query processor may >>even be able to expand some of the actions, rather than needing to >>treat Perl code as an "opaque blob." >> >>I would definitely be inclined to use the more natural language for >>the given task... > Is there a performance difference between the two? > which of the PL is most widely used. One problem i have with the > plpgsql is that the quoting is really a pain. You seem to be inclined to play the mistaken game of "Which language is the fastest?" which encourages myopic use of bad benchmarks. In 8.0, quoting in pl/pgsql is less of a pain, as you can use $$ as the begin/end indicators. Performance will always depend on what you're doing. - If you doing heavy amounts of "text munging," Perl has highly optimized library routines that you're likely to be taking advantage of which will likely be way faster than any pl/pgsql equivalent. - If you are writing "set operations," operating on table data, the fact that pl/pgsql won't need to 'context switch' between language mode and 'accessing data from the database' mode will probably make it a bit quicker than pl/Perl. - If you need some sort of "ultimate fastness," then you might look to writing in a language that compiles to assembler so that your loops will run as quick and tight as possible, which would encourage writing stored procedures in C. Alas, this is _way_ harder to debug and deploy, and errors could pretty readily destroy your database instance if they were sufficiently awful. pl/pgsql is almost certainly the most widely used procedural language, if you're into "popularity contests." I would be very much inclined to start with whichever language makes it the easiest to write and maintain the algorithms you plan to write. I would only move to another language if the initial choice proved to _systematically_ be a conspicuous bottleneck. -- output = ("cbbrowne" "@" "gmail.com") http://linuxdatabases.info/info/linuxdistributions.html "One of the most dangerous things in the universe is an ignorant people with real grievances. That is nowhere near as dangerous, however, as an informed and intelligent society with grievances. The damage that vengeful intelligence can wreak, you cannot even imagine." -- Miles Teg, Heretics of Dune