Re: Re: Getting last record ID created from DB

From: Date: Tue, 20 Mar 2007 23:49:54 +0000
Subject: Re: Re: Getting last record ID created from DB
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14  Groups: php.general 
Request: Send a blank email to php-general+get-250952@lists.php.net to get a copy of this message
markw@mohawksoft.com wrote:
markw@mohawksoft.com wrote:
http://www.postgresql.org/docs/current/static/functions-sequence.html It is perfectly safe to use this.
In theory that may be true, but can the application developer make any assumption about the underlying architecture? Might you be familiar with connection pooling? Where multiple threads or processes share a database connection or "session?"
If the developers of the database say it's safe, then I'm happy to take their word on it. If you can prove otherwise, please do so and post a bug report to them.
This isn't abut the database, per se' but connection pooling between the Apache/PHP process and the database. I can't tell you how many times I've seen that burn people.
In this case, tons of people are using connection pooling with postgres. If a problem had been discovered, then they would have complained and it would have been fixed.
I periodically participate on the PG hackers list, and if such a bug were reported, it would be bounced to the connection pool interface guys or ignored, because, it is essentially out of the control of the PostgreSQL developers.
Do I need to evaluate every section of code that a 3rd party provides to make sure the code does what the docs say it should? I'd never get anything done. At some point I just need to know how to use it and trust it works as it should. If it's a super critical application (eg financial information) where integrity is 100% required, then I'd test it. If I found a problem then I'd complain *shrug*.
You are confusing "PostgreSQL" with the connection pooling interface. I have seen this issue a few times with PostgreSQL and Oracle.
As Richard mentioned in another reply, the developers (whether it's mysql or postgres or "other") have taken a lot of pain to make sure these things work properly.
Again, it isn't about "PostgreSQL," because yes it does work if you go directly to PG, but if you use an interface that uses connection pooling to reduce resource usage, you are going to see problems.
Why would I try and do exactly the same thing myself and most likely get it completely wrong?
Because doing a a good web site, that really works, takes thinking about it, it takes understanding it, you can't be lazy and "trust" that someone else has done something, and then forget all the possible layers between you and it. That is *the* recipe for failure.
If I have to develop a website that handles a huge amount of traffic, of course I'm going to have to understand it all (well try to :P). 99.9% of sites don't and thus don't have to worry about this sort of thing. Until you get to that stage, is there a point in worrying about this sort of stuff? Maybe I need to get into developing more high traffic websites :P Going from a single webserver to multiple webservers and/or connection pooling is a big step, and you'd obviously have to test the crap out of your software/hardware before making the change "live".. and then deal with the issues that you discover.
The rest of your rant I agree with in theory, but making something "flexible" is extremely difficult unless you understand what you're trying to accomplish from the beginning - and know each system well enough to know how each one works and the differences between them. Not even "LIMIT" is standard across databases let alone anything else like data types ('int(11)' compared to 'int', 'datetime' compared to 'timestamp' etc etc etc) or even date formats that they store. Taking all of that into account from the very beginning is pretty tough.
If you going to do something, do it right, or else what's the point? Sometimes it is harder, but that's why being a professional is different.
So open source projects all need to be run & developed by professionals? Your original rant was about open source projects being "lazy" and limiting their thinking & support for different options. Doing a professional project is completely different to anyone starting an open source project. Most projects start out as 2-3 people developing it and then deciding to make it open source. When that happens, it gradually builds up and more people come on board. I still say it's pretty hard to take everything like this into account when you're starting out. Anyway this is getting way OT, I guess we'll agree to disagree ;) -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#250952) next »