Slashdot Mirror


MySQL Gets Perl Stored Procedures

ryarger writes "Woo Hoo! After a seeming eternity of wait, there is finally an implementation of stored procedures for MySQL. It uses Perl as the stored proc language, too!" Also note that this piece of work was done by OSDNs own Krow. Very cool work I must say.

73 of 266 comments (clear)

  1. Better stored proc languages... by Hagabard · · Score: 3, Interesting

    Why didn't they use a Transact-SQL compatible stored proc syntax? This would ease migrating and also enable people who prototype DBs on MySQL to move it to either Sybase or MS-SQL with a minimal of fuss.

    I'm not saying Transact-SQL is great or anything but it'd be nice if it was a bit more compatible with other systems.

    1. Re:Better stored proc languages... by bzhou · · Score: 2, Insightful

      Why is the suggestion of T-SQL funny? It's just an alternate, and IMHO a better-than-perl alternate. It's more compatible with core SQL and more compatible with the calling layer. I don't think people using Python or JDBC will be too fond of the myperl solution. T-SQL started from Sybase, not everything MS using is bad. But kudo and congrats to the myperl author anyway, at least people start to feel the need of stored procedures.

    2. Re:Better stored proc languages... by rjamestaylor · · Score: 2

      Why are you mad at me? Be mad at your clueless co-worker.

      --
      -- @rjamestaylor on Ello
    3. Re:Better stored proc languages... by denshi · · Score: 2
      Microsoft started MSSQL at 4.0, skipping the previous numbers to make the product *look* more mature. So, if the numbers are renormalized, MSSQL 7.0 is their 3.x effort. And yes, compared to their previous efforts, one might call it 'getting it right'.

      Of course, that doesn't mean it doesn't totally suck ass compared to Oracle, DB2, Informix, or even *Postgres*.

    4. Re:Better stored proc languages... by Earlybird · · Score: 2
      Microsoft didn't start at 1.0 because Sybase had already done that.

      Until 4.2, Microsoft SQL Server and Sybase SQL Server were one. Sybase later morphed into the Advanced Server Enterprise thingy, which incidentally runs splendidly on Linux as an alternative to the open-source stuff; Sybase is a solid product. Anyway, Microsoft bought the rights and forked the code, and MS-SQL evolved independently from then on.

      However, they remain highly compatible. The Sybase Transact-SQL flavour remains, as do most of the stored procedures, the client protocol (TDS), etc. Moving between the two implementations is simple, though I would personally never migrate to MS-SQL.

  2. Not a DB guru by Sir_Real · · Score: 2

    Could someone enlighten me as to the usefulness of stored procedures? Are they significantly faster? Are they easier to use than the straight jdbc/dbi api?

    Unenlightened

    1. Re:Not a DB guru by Overt+Coward · · Score: 2

      The biggest advantage is that all of the processing takes place in the database, so you don't have the performance hit of reading records out of the DB, doing the processing, and then sending back the results.

    2. Re:Not a DB guru by drudd · · Score: 2

      It's nice when you can code something up to run automatically... let's say you have several different ways a purchase order gets into your table, and you need to insert a row into another table any time a purchase order is added.

      Rather than having to remember to put that second insert everywhere you have a purchase order insert, it's nice to have it automatically run on the server (particularly since you don't have to communicate with the client).

      Another use is if you need to delete all of someone's addressbook when they delete their account... then you just monitor a delete on the "person" table and delete all records associated with it in the "addressbook" table.

      Doug

      --
      Venn ist das nurnstuck git und Slotermeyer? Ya! Beigerhund das oder die Flipperwaldt gersput!
    3. Re:Not a DB guru by msheppard · · Score: 2, Insightful

      SP's let you delgate a lot of the processing that should be done on the database (performance/encapsulation being good reasons to do this) to the database. And your biz layer doesn't have to do it and deal with the interface overhead. Things like complex sorting, or reference other tables.

      Given that ideal: Most stored procedures are just very complex select statements anyway.

      --
      Krispy Cream is people
    4. Re:Not a DB guru by smack.addict · · Score: 2
      Stored procedures are generally a bad idea in distributed and multi-tier Web applications. They are a product of the client/server era when there was no clear tier for business and logic and thus the only real way to share business logic was to place it in the database.


      Today, if you are building a multi-tier Web application, you should be placing your business logic in a mid-tier application server like Orion. Stored procedures, in this environment, have only a limited role for VERY specific optimizations.


      Perl stored procedures, IMHO, are an abomination.

    5. Re:Not a DB guru by rjamestaylor · · Score: 2
      Basically, it keeps application logic within the DB.

      One benefit, as you mentioned, is reduced data transfer out of the DB into the application over either a system bus or network connection (which can be a SERIOUS performance problem, especially if that network connection is thin or the application resides on a low-memory, slow CPU client).

      Secondly, this allows business-rule enforcement at the DBMS, instead of relying on the application logic to do the same. This second reason is perhaps more important than the performance benefit.

      The problem with SPs are: breaks n-tier model and increases processing strain on DB server (possible performance hit -- and increasing CPUs usually raises license cost of proprietary DBMSes), ties the application to the DBMS perhaps inextricably.

      --
      -- @rjamestaylor on Ello
    6. Re:Not a DB guru by CrackElf · · Score: 2

      The only time I ever used them was to create joins between a hierarchical and a relational database (using cobal rpc's). Of course the old hierarchical db should have been trashed years ago.

      The biggest advantage (that I see) is that it allows you to shift some of the work to the db engine / hardware. For instance, if you have a mainframe with a lot of extra cycles, you might want to shift some of the business logic to it instead of the transaction manager, or the client.

      The speed depends on the speed of the connection, the speed of the languages being used at the various tiers of the application, and the speed of the hardware at the various tiers, as well as the load. Are they easier to use? Depends on what language they are in, and which language you know better.

      -CrackElf

      --
      "Blake is an idealist, Jenna. He cannot afford to think." - Kerr Avon, Star One, Blakes 7
    7. Re:Not a DB guru by MrBogus · · Score: 2

      1) Stored Procedures should be considered a 'tier' in your application. They are the only real way to abstract your business logic away from your underlying database schema.

      It's true you don't want business logic in your SQL as much as possible, but you also don't want a bunch of hardcoded SQL in your business logic if you can help it. Stored procedures help here, even at the cost of seriously reduced portability.

      2) N-tier programming has the nasty habit of encourging very slow client-side joins and holding transaction locks over the wire. Especially if you get into (gack) EJB entity beans. If you can massivly reduce round-trips to the database by using stored procs, it's a clear win on performance.

      Perl stored procedures seems to have it all back-assward. Rather than doing the join on the client side with your 'fast' Perl, they push it into the database, which gives you the abstraction, but doesn't help you an ounce on the speed bit. I suppose this is sorta like running an EJB container in your database, but I'm not completely familiar with how that works.

      --

      When I hear the word 'innovation', I reach for my pistol.
    8. Re:Not a DB guru by drudd · · Score: 2

      You are correct... the primary uses for stored procedures are triggers, which is what I described, however they can be useful independent of triggers...

      Either way, a big advantage of stored procedures is avoiding communication with a client...

      Doug

      --
      Venn ist das nurnstuck git und Slotermeyer? Ya! Beigerhund das oder die Flipperwaldt gersput!
    9. Re:Not a DB guru by MrBogus · · Score: 2

      In all the applications I have been a part of, we keep the ERD pretty much the same as the OOD.

      This has been a problem with some of applications I've worked on. Suffice it to say that there has good reasons to let these diverge, and SPs can be used to hold it together, although you could use another application server 'tier' to do this.

      your DBA to hide the fact that he can't coherently design the datamodel

      Well, IMO, the DBA shouldn't be designing the data model or writing the stored procs and should stick to DBA things. Any project I've been involved in where there's a special 'database guy' has been doomed from the get-go as he basically has to do all of the application analysis *again* between worrying about backup schedules and managing database devices.

      please note that decent appservers can cache these Ejbs in memory so that many queries don't even hit the database

      It's true that you can 'disconnect' entity beans from the DB, but if you don't, you are holding a transaction lock over the wire. Plus EJBs are really bad for set processing (something that SQL is really good at). The idea of entity beans seems to be that the Java programmer can worry about java and not have to understand the database interactions. This is only true to the extent you are willing to suffer on performance.

      --

      When I hear the word 'innovation', I reach for my pistol.
    10. Re:Not a DB guru by SuiteSisterMary · · Score: 2

      Nope. Use stored proceedures so that you don't have to do this.

      Then, your web interface, your VB desktop app, your mainframe batch job, everything all calls the same stored procedure interface. The only time you have to touch code on any of these is if the inputs or outputs to said stored procedure change. Otherwise, database schema changes, table changes, none of it even remotely affects any methods you have to interface with the database.

      --
      Vintage computer games and RPG books available. Email me if you're interested.
  3. Yes and yes by wiredog · · Score: 2

    My experience has been that someone programming an app doesn't have to learn all the inticacies of Oracle, etc, to get work done. The dba writes procerdures and other people just call that procedure instead of writing huge ugle SQL queries.

  4. Subselects? by hetfield · · Score: 3, Funny

    My boss (Windows NT admin) and I were just discussing MySQL. We're running a number of small databases with Oracle on NT (with a University License), but we started talking about MySQL when I mentioned Slashdot was powered by it. Our web server and my workstation are Linux in NT land, and I try to plug Linux wherever I can. My boss is even learning Perl so he can code for our web server.

    He liked MySQL until he heard that it couldn't do two things: stored procedures and subselects. He said "I don't see how it could be useful without those things." All of the database apps he's ever written use those.

    It's great to see stored procedures being implemented. It would be even better if/when subselects are implemented. I could make a stronger case for moving some things over.

    Any chance of it happening?

    1. Re:Subselects? by baptiste · · Score: 2
      He liked MySQL until he heard that it couldn't do two things: stored procedures and subselects. He said "I don't see how it could be useful without those things." All of the database apps he's ever written use those

      Well if he needs those two things, why not mention PostgreSQL to him? It can do both things - its a more feature complete DB than MySQL though in SOME cases its slower. But it all depends on teh application and just like WIndows vs Linux you'll see lots of MySQL vs Postgre flame wars too. I use both. I use MySQL for web based apps that have fairly simple backend needs and PostgreSQL for more complex setups.

    2. Re:Subselects? by dorkstar · · Score: 2, Interesting

      Well, this probably won't help convince your boss, but IIRC subselects are mathematically unnecessary. You can flatten any query down to a single select and what you get is much more efficient. Read the real scoop in the first chapter of any database textbook.

      Actually, IIRC it's not even that hard to do it for 90% of queries...

  5. But wait... by don_carnage · · Score: 2

    WoohooO! Now, if they can only work out sub-queries, then I'd be 100% happy! Oh yeah...and get something like SQL*Loader cause I hate doing it the other way!

    1. Re:But wait... by krow · · Score: 2

      You know, most of the time someone using a subselect just lacks the imagination needed to do a join :)

      On a serious note, you will find that most of the time a subselect ends up being your worst nightmare for performance reasons. Its normally better to find a way around them.

      --
      You can't grep a dead tree.
    2. Re:But wait... by don_carnage · · Score: 3, Interesting

      Yes, but it's a nightmare trying to perform an extended update without subselects. I usually end up just writing a small Perl proggy to do it with DBI.

    3. Re:But wait... by bwt · · Score: 3, Interesting

      You know, most of the time someone using a subselect just lacks the imagination needed to do a join :)

      While some people will always do brain dead things, there are definitely many queries that you simply cannot write unless you do subqueries.

      Consider something as simple as finding all students whose IQ is above average.

    4. Re:But wait... by krow · · Score: 3, Interesting

      Oh very true. Sometimes you can't get around using subselects (there are a couple of places in Slashdot that are exactly in this situation).

      There are other things I would rather see though. For instance in Oracle you can represent Graph structures in the databases (quite cool). I would love to have this for comment storage. Right now it is quite a pain in the ass to generate the comment pages in threaded/nested mode.

      --
      You can't grep a dead tree.
    5. Re:But wait... by bwt · · Score: 2

      I assume by storing graphs, you are refering to oracle's "connect by prior ... start with" syntax -- which definitely rocks. It should be added to the SQL standard.

      In-line views (from clause subqueries) are very useful, and starting in one of the 8i versions, you can even do subqueries in the select clause, which is sort of an inline-function. The analytic SQL functions are pretty cool, too, but Codd is probably rolling over in his grave about them.

      The best new oracle SQL functionality though, is unquestionably materialized view SQL rewriting, which is sort of like using a view as an index - it stores the results and uses them transparently to rewrite SQL plans that would recalculate things. The affect on things like simple slice-and-dice tallies is just incredible.

  6. This would have been great, fifteen years ago. by The_Messenger · · Score: 2, Troll
    Wow, now they only have to implement constraints, foreign keys, and transactions, and they'll almost be on the level of Postgresql.

    Who knows, maybe MySQL will one day be considered a real database product.Until then, though, those of use doing Real Work will continue to use Oracle, DB2, and SQL Server. Of course, these databases already have professional GUI development tools, spatial data modeling, XML table translation, and tons of other fun toys, so the MySQL developers better get to work!

    Honestly, besides cheapo webhosts and poorly designed weblogs, who uses MySQL?

    DB2 rocks on GNU/Linux, by the way, and it's free as in beer. You should check it out.

    --

    --
    I like to watch.

    1. Re:This would have been great, fifteen years ago. by mgkimsal2 · · Score: 2

      it's free as in beer

      Really? Can you point me to a place on IBM where I can get DB2 on Linux for free? There seems to be NOTHING about how to actually PURCHASE their DB2 (broken links or circular references).

    2. Re:This would have been great, fifteen years ago. by krow · · Score: 2

      Actually, Slashdot's user tables are innodb (the transaction tables). So is the stories table. So far innodb has turned out to work really well. We have always had problems with the SELECT/INSERT penaltly and Innodb has solved that for us.

      --
      You can't grep a dead tree.
    3. Re:This would have been great, fifteen years ago. by krow · · Score: 3, Interesting

      Actually the code for the DB is very modularized. You just have to exchange one library and you can use a different databases. I have tinkered with this for PostgreSQL and Oracle but never for any other DB (while I have experience with Sybase and Informix, I have never used DB2).

      I have had people from IBM approach me about doing a DB2 port, but no one has every offered any code and I have enough to do as is.

      One of these days though I would love to setup slash on an IBM mainframe and actually benchmark it. I suspect it would run quite well (even with MySQL).

      --
      You can't grep a dead tree.
    4. Re:This would have been great, fifteen years ago. by Reality+Master+101 · · Score: 2

      DB2 rocks on GNU/Linux, by the way, and it's free as in beer. You should check it out.

      Have they implemented autoincrement columns or sequences yet? That's by FAR the most detestable thing about DB/2, and in fact, is one reason I generally recommend against it.

      --
      Sometimes it's best to just let stupid people be stupid.
  7. I do hope this is the beginning and not the end... by leereyno · · Score: 2

    Having stored proceedures in any language is better than not having them. The advantages of them are that they can be readily used by other programs, and they don't have to be compiled to be run, so they are faster. Since perl is an interpreted language I'd suspect that the latter benefit is lost. So what I'm hoping for is the future inclusion of stored proceedures written in SQL itself like what is offered in other DBMS systems.

    Lee

    --
    Muslim community leaders warn of backlash from tomorrow morning's terrorist attack.
  8. Hmmm....perl....haven't we learned from Oracle? by mbpark · · Score: 4, Interesting

    What I find extremely funny about this all is that Microsoft is doing the same thing in SQL Server 9.0, by putting the CLR in the SQL Server database. This way you can write your procedures for SQL Server in many languages, including Perl. OUCH. It causes more overhead than you realize to have an interpreter for more than SQL in the database.

    I'm a DBA. I have seen the last few versions of Oracle with their Java Stored Procedure and SQLJ support, which is pretty bad. Oracle can't even get their PL/SQL running right between queries and views and stored procedures (the engine has not changed for PL/SQL since 7.3 in 8i, and 9i does not change it that much. Yes, they run 2 engines, one for SQL and one for PL/SQL. It makes Oracle perf tuning a complete nightmare). Yet they find it necessary to shoehorn a complete JVM in. No, no one really uses it, because it doesn't provide advantages.

    It only makes the code completely unmaintainable since it's nothing more than code that calls the internal JDBC driver rather than an external one.

    PL/SQL, T-SQL, and the other stored procedure languages at least are written in a superset of the main DML/DDL language. This allows you to use the same language optimizer, which reduces code size, and allows for code consistency across the entire project. In other words, all the queries, including parts of stored procedures, get the same optimization treatment.

    Having ONE optimizer means that you can make it run really well, and share query plans and cached information. Pretty cool :).

    The other important reason you have stored procedures is because if they are written in the main language, you can leverage the optimizer for query plans and caching of frequently-used or prototyped statements. That's part of the other reason for stored procedures. You can share queries and query prototypes with views and user queries, and have optmization that is better than what writing a procedure in X language can do.

    Now we've got Microsoft coming in with their CLR, and mySQL using Perl. This is going to lead to even more unmaintainable code, because you're going to have people coding business logic that can be optimized in the DDL/DML language used in a higher-level language that cannot be.

    Talk about a performance problem :).

    From a language and optimization perspective, you always try and use a derivative of the main DML/DDL language of the database, so that you can use the same optimizer for making the statements run faster and perform well.

    Anyone can write internal hooks to have a code interpretation engine in a SQL database. Oracle's been doing it for years, and so has Sybase. No one I know uses it because it doesn't provide the real advantages of stored subprograms in a database, which is to store frequently-used and prototyped query statements and aggregations in such a way so that they can be optimally retrieved versus just executed. When you add additional languages, you lose that. Oracle's Java Stored Procedures are nothing more than Java code that calls a different JDBC driver. I don't even want to think of what ADO.NET is going to do in SQL Server 9.

    While this seems like a good idea, remember that it's been out for a few years in two other products, and is coming out for another. It's not as big a deal as real SQL stored procedures, because it's not as optimal as they are due to their loose coupling (which describes it perfectly IMHO), and can't share in the same optimization techniques as user SQL queries.

    In other words, this isn't something to be too happy about, since it's something that people already have and don't use.

    1. Re:Hmmm....perl....haven't we learned from Oracle? by sheldon · · Score: 2

      Does mySQL even implement caching of query plans?

      I can't find any information to suggest that it does, so maybe this doesn't really matter.

  9. Re:WTF? by dameatrius · · Score: 3, Informative

    Actually, this is very useful. If you want to do say 6000 inserts using a comma delimited string or something along those lines, to open a connection and call a specific stored procedure is EXTREMELY slow compared to parsing the string internal to the stored procedure (recent test I did when designing some software showed an insert called 6000x took 16 seconds compared to 1.5 seconds parsing the string in the db). Now when you use a language like java or perl to do that internal to the db, it will drop that time even more as SQL design wise has string manipulation features but isn't meant to be doing it. I would much rather have a Java parser that I call inside my sp and have it take half a second versus 1.5 seconds to have PL/SQL parse my strings. If you actually did any development involving database interaction, this would be pretty obvious.

  10. Mysql todo list by Jeffrey+Baker · · Score: 3
    Great! MySQL crosses off another thing on their list of things they need to do to catch up with PostgreSQL:
    • New logo (check)
    • Stored procedures in Perl (check)
    • Stored procedures in C, C++, Python, TCL
    • Langauge similar to PL/pgSQL
    • User-defined datatypes
    • Transactions
    • Subqueries
    • Constraints
    • Stop being a bunch of whining Euro sue-boys

    Looks like it might be a while. Better just get PostgreSQL in the meantime.

    1. Re:Mysql todo list by Jeffrey+Baker · · Score: 2

      Wait, I forgot sequences.

    2. Re:Mysql todo list by gmhowell · · Score: 2

      You'll probably get flamed for mentioning the lawsuits, but lately, I've been thinking about switching to postgresql. Not only for subselects, but because there is a clear source for updates, upgrades, etc.

      If you're running on ancient hardware, or running a huge database, perhaps the speed is important in MySQL. But for my needs (relatively modern hardware, and small datasets) why deal with it?

      --
      Jesus was all right but his disciples were thick and ordinary. -John Lennon
    3. Re:Mysql todo list by Jeffrey+Baker · · Score: 2
      I'm used to meditate on how this attitude came to be, but now I believe simply that most MySQL users are natural idoits. MySQL is shit slow. Insert block selects. Even selects can block selects. MySQL lack concurrency in a big way. In PostgreSQL, there is hardly ever any kind of blocking at all. Selects don't block inserts nor the other way about. Certainly no select can block another select.

      PostgreSQL is way faster than MySQL in everything besides some contrived read-only benchmarks. In actual benchmarks and the real world where the rest of us live, PostgreSQL's performance shines above MySQL's in every way.

    4. Re:Mysql todo list by SuiteSisterMary · · Score: 2

      If all your after is speed, then append to a text file. Appending and grepping your results is a hell of a lot faster than MySQL.

      --
      Vintage computer games and RPG books available. Email me if you're interested.
    5. Re:Mysql todo list by nagora · · Score: 2
      Yep, PostgreSQL only needs to tick off one thing to catch up with mySQL:

      Usable.

      --
      "Encyclopedia" is to "Wikipedia" what "Library" is to "Some people at a bus stop"
  11. I would also like ... by Da+VinMan · · Score: 2, Insightful

    if they put hooks into a generic MySQL facility which allows *any* programming language to serve as a SP language in the server. Why can't I use Python? Why can't I use xxx? It's widely rumored that Microsoft is doing this same thing for the next version of SQL Server, so this really isn't such a radical idea. The trick is to devise an abstraction within MySQL that represents all stored procedure capabilities, and then interface each target language to that layer.

    I agree that having a Transact-SQL equivalent will be key to consideration by serious database users, but it's just a starting point.

    --
    Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
    1. Re:I would also like ... by ethereal · · Score: 4, Insightful

      I wouldn't bitch about performance too much - if that's all you want, just ditch SQL entirely and use an embedded DB like Berkeley. Truth is, features/performance is a sliding scale, not a binary option. For some applications, being able to use stored procedures in a few different languages might be very helpful. For other applications, an SQL parser itself is unacceptable overhead.

      --

      Your right to not believe: Americans United for Separation of Church and

    2. Re:I would also like ... by Dasein · · Score: 3, Insightful

      A vast majority of the performance gains to be had from stored procedure programming comes from two sources -- precompilation and elimination of network round trips.

      Neither of these options are precluded by a correct abstract interface.

      There's no doubt that such an abstract interface would hurt performance, but I would venture to say that you would give back much less than 1% of the stored procedure benefits by doing this. You can do a large number of JNI-Like calls in the ~8ms required to complete a network round trip. Add compilation and query optimization and you have a large number Vs. a very small number.

      To be able to provide a migration path for both sers of MS SQL Server/Sybase, Oracle, and DB/2 seems compelling even though and such migration path is likely to be an 80/20 proposition.

      Not a bad idea, in my view.

      --
      You are not a beautiful or unique snowflake -- but you could be if you got off your ass.
    3. Re:I would also like ... by Malcontent · · Score: 4, Informative

      " if they put hooks into a generic MySQL facility which allows *any* programming language to serve as a SP language in the server. Why can't I use Python?"

      Postgresql does this. You can use python, perl, TCL, and PL/PGSQL.

      They are debating loading up Java but there seems to be some resistance from the hackers.

      --

      War is necrophilia.

  12. The crowd may not like this, but it's true by DaveWood · · Score: 2

    PERL is not a good language, and probably an especially bad choice for a stored procedure langauge.

    The syntax is a mess, and like many basic-esque languages it's very easy to get into namespace trouble. There are gotchas with strings and escape sequences. Memory is managed with a reference counting garbage collector, which means circular dependencies will create memory leaks; this isn't as serious with kludge maintenance and CGI scripts, but on a database it will be of signal concern. What passes for a language API is what I would call deliberately obscure (lots of one and two letter functions, a million operators, &c &c). On the whole, it's a complete horror show, and just as with Win32, I'm continually amazed at how many things get written against it.

    I say stop the cycle of abuse. There are over a dozen free languages that would have been a 100% better choice.

    1. Re:The crowd may not like this, but it's true by Christianfreak · · Score: 2

      Maintainability just sucks.

      No. Programmer's who can't/won't write commented, readable code suck. Last time I checked you can make any language look like a mess.

    2. Re:The crowd may not like this, but it's true by c13v3rm0nk3y · · Score: 2, Interesting

      Boy, are you going to get flamed.

      I've had a love-hate thing with Perl since I first saw it. I appreciate it's power, but scratch my head over some of the design choices. And the syntax! Inscrutable.

      I do marvel at it's versatility, however. Perl. Is there anything it can't do? That being said, it's just too big for most of the work I do. If I need to hack a script together, I just reach for the Kornshell.

      I've used Perl to prototype, and at that it excels, but the maintenance required for anything else hasn't given me the warm fuzzies. You have to be a bit of a wizard to showcase the elegance buried in Perl, and I just can't take the time. I'm sponsored by my company to increase my Java and C kung-fu, and <code>use Perl;</code> is just not part of our culture.

      Anyway, to actually finish on topic, the db-powered app my company uses had ruled out mySQL, even on Linux, for lack of store procedures. The introduction of Perl is not going to change this significantly. Compared with Informix, mySQL rules, but it's not corporate-ready, at least for this corp.

      --
      -- clvrmnky
    3. Re:The crowd may not like this, but it's true by VB · · Score: 2

      And, some languages defy any attempt to not look like a mess, regardless of commenting:

      Private Sub Combo91336_AfterUpdate()
      ' Find the record that matches the control.

      Me.RecordsetClone.FindFirst "[IndexField] = " & Me.Combo91336.Text
      Me.Bookmark = Me.RecordsetClone.Bookmark

      End Sub

      Wait; sorry that's not a language. >:)

      --
      www.dedserius.com
      VB != VisualBasic
    4. Re:The crowd may not like this, but it's true by EvlG · · Score: 2

      This post hints at the real cause of the "Perl is unmaintainable" mentality that pervades the community with the statement that begins "I've used Perl to prototype..."

      Therein lies the problem. Perl really helps the programmer get something done quick. Much moreso than C/C++, and somewhat moreso than Java. However, that speed always comes at a price. Its a lot harder to read code that isn't commented, and that is chock full of clever tricks gleaned from reading comp.lang.perl. The same would certainly be said of C/C++ coders using lots of shortcuts from books and FAQs, and possibly of Java as well. Arguably, Java does enjoy the advantage of verbose method and class naming. This does help make the code a little easier to read, but this isn't something exclusive to Java. Any good programmer should name things properly. Besides, some argue that Java can be too verbose (like Objective C is IMO) and that makes it just as hard to read as if it were too concise.

      The real solution is something that is taught in Software Engineering courses, but often ignored: THROW AWAY THE PROTOTYPE. A prototype is meant to be a quick and dirty proof-of-concept, something to give everyone an idea of what the tool is supposed to do. You will run into problems when you extend a prototype into production, whether you are talking Perl, Java, C/C++, or any other language. Prototypes are developed quickly and without much planning. It is this lack of planning that is at the root of most maintenance problems.

      Well-written Perl with helpful comments and a good use of whitespace is easy for experienced Perl programmers to read. That same can be said of well-written Java and C/C++. Some even say the expressive nature of Perl can make the code easier to read, and I'd agree. However, I don't believe Perl is inherently unmaintainable. I think that myth is an unfortunate side-effect of Perl's ease of use. You can develop a solution very quickly in Perl, and it will work. But it is unreasonable to expect a maintainable solution to come out of any significant programming project that lacked planning and consideration. Anyone who does prototyping in C/C++ and Java would recognize that it wont be maintainable for production use. Too many simple assumptions are made, and the implementation is often tied too closely to the interface. This is a problem with prototypes in ANY language. Why do some people expect Perl to be different, just because it allows the developer to prototype faster?

      Thus, while it may be true that Perl code is often unmaintainable, I don't put the blame on Perl. I place the fault squarely on the shoulders of those who mis-use their prototypes, and don't want to pay the price later.

    5. Re:The crowd may not like this, but it's true by MikeBabcock · · Score: 2

      Protoyping & Applications: Python
      Text-processing tools: PERL
      Prototype that should've been thrown out: BIND.

      --
      - Michael T. Babcock (Yes, I blog)
    6. Re:The crowd may not like this, but it's true by DaveWood · · Score: 2

      I have. I am.

  13. Actually by Micah · · Score: 2

    I've looked through the Slash 2 source code and poked around it some and plan to write some plugins. They didn't do a bad job at all. Sure, Python would probably be a better choice, but Slash is better than 85% of Perl code out there.

  14. Cram your Mod points... by bwoodring · · Score: 4, Insightful
    > Why in the HELL would you want another layer in there? For flexibility?

    You don't know the first damn thing about database programming, do you? The stored procedure code isn't re-parsed every time it's run. The execution plan for the query is cached and *that* is run. The performance hit would only be seen the first time the SP was run, when the recompile occurs. Having multiple SP languages would be a very good thing.

    > You need performance, period.

    No, not really, it is that kind of attitude that got MySQL into the position it's in today, everyone acknowledges it's fast, but nobody has any respect for it as a real database.

    > If they actually wanted MySQL to be used by people who knew what they were doing, they would've integrated in PL/SQL.

    No no no, damnit. We need to get past these shitty Procedural SQL hacks. T/SQL and PL/SQL are crap, Why do you think Oracle is integrating Java and Microsoft is integrating ActiveX into the database engine? Because trying to do high-level programming in SQL is complete shit. Why would MySQL want to integrate a legacy language like PL/SQL?

  15. Re:From stories past... Slashdot funds MySQL? by krow · · Score: 2

    I am gone to Linux World Expo, when I get back the failover should be in place. I have been testing the new replication stuff and it seems to be working fine for me (this is for Slashdot).

    --
    You can't grep a dead tree.
  16. One other reason by Dalroth · · Score: 2, Insightful

    A lot of you people are forgetting two other critical reasons why stored procedures are good.

    1. Most database pre-parse the stored procedures and keep the cached parsed information in memory. Really complex SQL queries can take a significant amount of time to parse, and cutting down on that overhead can be a huge win for some applications (it was for one of our queries!).

    2. Stored procedures can encapsulte logic that requires multiple SQL queries into one call. This saves the network overhead of making multiple trips to the database, which can potentially be huge (and even be REALLY huge if you open up a new connection for each SQL query and then shut the connection immediately).

    I don't know if the Perl procedures remain parsed, but at the very least they should be able to accomplish #2. Personally though, I'm going to wait till mySQL supports some sort of Transact SQL like stored procedures. I don't see a justifiable reason for the overhead involved in running Perl on my database. That just strikes me as a bad idea (same goes for java).

  17. Oracle Perl Stored Procedures? by Craig+Maloney · · Score: 2
    I wonder if Oracle will allow Perl Stored Procedures. I despised PL/SQL when I had to use it, since I could do everything PL/SQL did in Perl (minus triggers).

    Well, one can dream, can't they? :)

  18. Re:There are very few cases for stored procedures by beanerspace · · Score: 2



    Certainly, there are limitations, but to say there are very few cases ignores situations where programmers are migrating from thick to thin clients, using the same query between various languages and is unsure or not satisfied with client-side performance.


    Just a very quick example. Let's say you wrote a database application using, oh, I dunno, Sybase and Powerbuider about 4 years ago. Now the client wants everything web-based. Guess what ? Your stored procedures work just fine in the JDBC and the PERL DBI. Problem is, all your code is in client-side/inline sql.

  19. Re:From stories past... Slashdot funds MySQL? by krow · · Score: 2

    Right, which is more then a little tricky since MySQL lacks two phase commit support. Its still going to require a human to do the work. But it will be possible at least. We have backups but no way to switch to those on the fly.

    I added the static page option about half a year ago so that folks can at least see the front page when we loose the DB.

    --
    You can't grep a dead tree.
  20. A crust of bread to a hungry populace... by dasmegabyte · · Score: 3, Interesting

    PERL????

    Jesus, PERL????

    You know, the strength of query languages is that you don't have to use (and in face, are usually punished for using) loops and cursors to make massive changes. Perl is the most loop oriented language on earth. And even if, underneath it all, the optimizer is turning your code into a loop anyway, it's goddamn doing it more efficiently than Perl ever would. This addition is NOT going to increase the likelihood of people migrating from sybase or other TSQL based databases to MySql...it's going to increase the number of hardliners who feel that MySQL is a pathetic ghost of "real" servers, and as such decrease the cadence of better open source solutions like PostGreSQL. MySQL and Perl...it's fast becoming a database for control freaks who don't believe in doing anything automatically, or allowing the machine to do our optimizations for us -- and that's what computers are all about, goddamnit!

    It is nice that there's finally a way to perform object operations on a server without performing the logic in scripted code, and it's nice that MySQL is trying to make a grab for usefulness beyond its INSERT, SELECT, DELETE simplicity. But Perl is not a standard language in the DB world...it's asking for DBAs and programmers used to TSQL and looking for a cheaper, freer alternative to gain new custom knowledge that is complex and no better then the knowledge they already have! All those linux sysadmins to have a little database are going to be overjoyed...but for the rest of us, this is totally useless, just like the rest of MySQL's features.

    --
    Hey freaks: now you're ju
    1. Re:A crust of bread to a hungry populace... by nagora · · Score: 2
      Perl is not a standard language in the DB world..

      It is now.

      --
      "Encyclopedia" is to "Wikipedia" what "Library" is to "Some people at a bus stop"
    2. Re:A crust of bread to a hungry populace... by dasmegabyte · · Score: 2

      Oh, excellent point. MySQL, a common database among non-DBAs, is creating a "new standard" rather than using the one that's available. It seems to me that that's widening the rift between those in charge of maintaining and optimizing database interaction and a non-optimizable database (okay, in all fairness you can optimize MySQL well enough, but not as easily or with as much benefit as other SQL servers). And in a world where marketshare is often determined by supportability, it seems that MySQL is telling decision makers "hey, you can use our database, which is inefficient and inelegant but maintainable by your cheapest UN*X admin." That's great and all for small databases...but for anything that's intended to scale (that means with an increased development personnel base as well as an increased server load) it seems to me that clinging to the defacto standard makes more sense than creating a newer, shittier one.

      And it's not even like a TSQL stored procedure system is hard to implement! The MySQL programmers are just more Open Sourcers lost in an idiom of freedom that says that a feature is better released as a halfassed hack than an actual solution. But then again, with all the foolish squabbling between developmental agencies, it's a surprise they get anything done at all.

      This "feature" only means that they'll eventually have to add an adjunct system for writing stored procs in TSQL, adding to the bloat of the application and slowly destroying the only nice feature of this server: how quickly and efficiently it can return a simple rowset.

      --
      Hey freaks: now you're ju
  21. I think that's the point of T-SQL and PL/SQL... by Da+VinMan · · Score: 2

    and it's a worthy goal. Unfortunately, there's two major problems with them:

    1. Too many people use them for procedural programming anyway. There's just things you can't do otherwise, so the capability has to be there. But the capability is often abused.

    2. They're too proprietary. I'm not up on ANSI SQL standards enough to know by how much each one deviates and whether the ANSI standard provides a complete enough standard for SP operations, but it occurs to me that MySQL could stand to gain a lot by exactly toeing the ANSI standards line. Just a thought I guess.

    --
    Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
  22. Re:FYI - is this what you're talking about? by denshi · · Score: 2

    Which is a shame considering cursors are high performance basic components in Oracle and Postgres.

  23. Re:Why not stored procs in SQL? by SuiteSisterMary · · Score: 2

    Stored proceedures generally need things like variables, control statements, loop capability, stuff like that. SQL doesn't have those.

    You'll notice, however, that most other DBs implement sql-like extentions that make sense in their own context; Oracle has 'Procedural Language SQL', SQL Server has 'Transact-SQL' and so on.

    I haven't looked at it at all, but I get the impression is that what these guys have done is given you the ability to point to PERL scripts and say 'run that when I tell you to' which is NOT stored procedure capability, but close.

    --
    Vintage computer games and RPG books available. Email me if you're interested.
  24. Schwartzian Transforms take on a new level! by ajs · · Score: 3, Interesting
    Wow, can you imagine doing
    • UPDATE 'foo', map { ... } grep { ... } sort SELECT 'bar', ...
    This is the heart of the power of Perl, and if the interface is built right, it could be a huge boon to database work.

    Of course, done wrong it could be slow, difficult to maintain and immediately obsolete.
  25. Such as Java by Baki · · Score: 2

    If anything, then Java.
    Oracle even moves PL/SQL (which isn't bad either) to Java. I'm sure Java will be the de facto SP language in the future for Oracle and DB2 (which have more than 60% of the market together). Just drop a JVM in the database core, and write a special JDBC driver for this.

    No need to implement and maintain a fully new language.

  26. Postgresql by jabbo · · Score: 2
    Pgsql has subselects, joins, replication, write-ahead logging, transactions, and has had Perl as a procedural language for years. It's not quite as fast as MySQL, and it doesn't have as many idiots writing knicknacks for it in PHP, but the most useful ones IMHO (Thoth, ACID, PgMyAdmin, OpenACS, etc.) run fine on top of it. If you need transactional/sp features and do not want to pay for Oracle, it may be your best choice.

    Postgres home page

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
  27. SQL sucks by chrysalis · · Score: 2

    Most people are using SQL engines just to store basic records, that sometimes even don't need any sort of indexation.
    SQL engines are slow and unreliable. Almost everytime I see a web site down (even Freshmeat) it's due to a database crash. SQL is a brain damaged query language. SQL tables have an horrible obsolete Cobol-like structure (every record must have a fixed len to be handled efficiently, types are fixed, etc) .
    Sure, they can be useful for something.
    But for 99% of the projects they are used for, they could be easily replaced with a simple indexing library like CDB, GDBM or BerkeleyDB (BDB itself is very powerful, it has a lot of nifty features, plus it's rock solid and damn fast) .
    Or even flat files. I've seen so many people using complex SQL tables just to store 50 poor records. Just crazy. Do people know that filesystems can store data, too ? Does Squid need Oracle to store the cache ?
    I never used SQL (although I coded large search engines and other stuff that stores and index a lot of data) . And I don't want to. BerkeleyDB achieve the same thing on a 386 than *SQL on a Thunderbird.

    --
    {{.sig}}
  28. Same thing we always knew by Proud+Geek · · Score: 2

    Basically, it says that MySQL is faster and more stable, and that PostgreSQL has transactions. Which is more important? How about a database that doesn't crash when you put a tiny bit of load onto it. I'll stick to MySQL, thank you, and the addition of Perl as a language for stored procedures will make it even better and more useful.

    --

    Even Slashdot wants to hide some things

  29. Re:Really?! by Malcontent · · Score: 2

    I certainly wouldn't use postgresql on windows (although I might if I bought it from great bridge). If you want a windows DB that open source, proven, stable, mature, reliable, fast, supports stored procedures, triggers, and has fantastic GUI tools may I recomend interbase. It does not have loadable stored procedures but does support domains and column level localization. Also consider SAPdb which is a very robust server from SAP the giant ERP company. They open sourced it a while ago.

    --

    War is necrophilia.

  30. Language X possible through Perl Inline Module ? by mattr · · Score: 2
    I don't know if this will work with the subject of this story, but if the Inline module is supported it will let you also use Python, Java, C, C++, Tcl, Assembler, Guile, and whatever somebody else feels like glueing in.

    Ought to work.. anybody tried using it?

  31. Re:Comparison Mysql vs PostgreSQL by denshi · · Score: 2
    Man, that's a funny page. On stability, he compares MySQL 3.23 with Postgres 6.4 -- a 4 year old product. Suprise! Guess which is more stable.

    All I want to see is just *one* benchmark from the MySQL folks that isn't blatant dishonesty or incompetence.