Re: Choosing Between PL/PGSQL or C/C++ for Triggers/Store
От | Dmitry Tkach |
---|---|
Тема | Re: Choosing Between PL/PGSQL or C/C++ for Triggers/Store |
Дата | |
Msg-id | 3EE8E4A5.8010001@openratings.com обсуждение исходный текст |
Ответ на | Choosing Between PL/PGSQL or C/C++ for Triggers/Store Procs (Clay Luther <claycle@cisco.com>) |
Список | pgsql-general |
I use C for the following reasons (in order of importance - to me, of course): 1. tired of having to lear new languages :-) I was always wonderring why does every database vendor have to invent their own syntax? Why not stick to something existing, well defined and known to work - like perl, for example.... 2. Flexibility and functionality - you can do *anything* in a "C" stored procedure. Literally - it is loaded into the postgres process, and you can call any function you want, without being limited to what pgsql thinks you are going to need... Of course, if you do it wrong, it'll crash, and you are on your own.... But I am willing to take the risk for the benefit of being able to do stuff I need to do. 3. Maintainability - if you wrote a function (*especially* a trigger), and it doesn't seem to be doing what you want, what do you do? If it is in "C", you can attach to it with a debugger, set a breakpoint, and look at what is going on, and if it is in pgsql... well, unless I don't know something important about it, your only choice is going to be to stare at the code and try to guess what the hell is wrong with it . 4. Performance - generally, a C function will be faster just because it does not have to be interpreted, but, I believe, the difference will be miniscule... The main advantage here boils down to the item #2 above - the flexibility. In a C function you can go right after what you want to do, and do it just the way that will be quickest in your particular situation, you deal directly with the data structures you intend to modify, and do not waste time on converting them back and forth, you can keep caches, do binary searches or hash lookups... whatever you want to speed it up. Dima Clay Luther wrote: > For a very complex database in which we plan to implement database > rules via triggers, I need some information on which language, > PL/PGSQL or C/C++ provides the most "bang for the buck" with respect > to performance. One initially presumes the C/C+ stored procs/triggers > will be faster, but after reading some posts on the list about the > Query Planner and PL/PGSQL, I was wondering if using PL/PGSQL might > not be better. > > 1) Is there a clear-cut choice when performance is the issue? > 2) Is there a fuzzy choice at work here? Perhaps PL/PGSQL for simple, > obvious stored proces/triggers, but C/C++ for complexity? > > Thanks. > >-- >Clay >claycle@cisco.com >
В списке pgsql-general по дате отправления: