Hacker Newsnew | past | comments | ask | show | jobs | submit | lpsmith's commentslogin

There is a good chance that your proposed algorithm to enforce a uniqueness constraint in the application won't work. As in, you've left out enough details that would be critical for getting it right, and in my experience, a lot of programmers would only get this right by accident if they get it right at all.

First problem is that the SQL standard provides no way to make this work portably on any standards-compliant database. So right there you are going to have to code to the database to one degree or another.

So, let's say you want to make this work in Postgres. Now, you'll need to be using Postgres 9.0 at least; otherwise your uniqueness constraint won't be a uniqueness constraint.

Try this, in any version of Postgres. Open up two psql sessions. In one, run a `create table unique (x text);`. Then run `begin isolation level repeatable read; select * from unique where x = 'foo';` in one of the sessions. Repeat those two commands in the other sessions.

Neither session sees 'foo'. So now both can go ahead and run `insert into unique values ('foo'); commit;`. Both transactions will succeed, and you can confirm that there are now two instances of 'foo' in the table.

In fact, `begin isolation level serializable` in PostgreSQL 9.0 or later is the minimum isolation level to make this work. And, you will need retry logic around the transaction in case of a serialization failure. (Perhaps your DB access layer or language would hide this latter detail from you, or perhaps not.)

In PostgreSQL 8.4 and before, serializable and repeatable read were equivalent, and both were still SQL standards compliant. In PostgreSQL 9.0, the repeatable read isolation level stayed the same, while the serializable isolation level was strengthened.

Unless you can accept a certain level of degraded accuracy by using a probabilistic construct such as a Bloom filter, by far the biggest cost of maintaining uniqueness is the index. And you'll need that index whether you use the database or the application to enforce uniqueness.

And, judiciously pushing computation onto a database can actually be cheaper for the database as well as its clients. This scenario is likely to be one of those situations.


Well, those kinds of claims are kind of par for the course for the Python community. I remember that it was commonly claimed that Python 1.5 had the "full power of the lambda calculus", when all it had was anonymous function definitions, and not true higher order functions.


I can think of a lot of software that's priced in the $1000-10000 range.


I've wondered about that and wondered how much of that is due to a total sale adding up to much more than $10K?

And of course that's not a hard rule, there can be software priced in the middle where a less strenuous effort on the part of the corporate buyer gets the job done on his side (and many think that a major reason for corporate software piracy is not that the corporation can't afford it, but that it's so hard to get a purchase order through that borrowing a disk from someone across the hall is by far the path of least resistance).

And maybe this help explains some major failures, like Centerline's Code and ObjectCenter (interpretive environments (with interpreters, but you often just load compiled code on the fly) for C and C++ that are as close to a Lisp Machine as you could get for those languages).

Also, the $1,000 limit is undoubtedly too low, it's whatever your corporation allows you to spend without too much effort (e.g. CxO signoff). A few thousand dollars are OK, e.g. that's how PCs slipped into a lot of companies, on departmental but not corporate budgets. (Heck, that's how a few Z-80 CP/M machines slipped into LMI when we had at most 3 CADRs operational at a time and a strong bias against doing anything outside of a Lisp Machine.)


Indeed, even though a "series of tubes" is a relevant analogy, it's still plenty obvious that Senator Stevens is clueless with regard to the Internet.


What's there to disagree with? It's one big glittering generality and I wouldn't be at all surprised that the author is grievously misrepresenting the positions of his opponents.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: