Better HN
topnewbestaskshowjobs
Log inSign up

wireprotocol

7,244 karma · joined Sep 25, 2010 (16y ago) · 2,593 submissions

Submissions

comment 14y ago · link · parent

I just wanted to make the connection to suffix trees: http://en.wikipedia.org/wiki/Suffix_tree

Because those can be better than btrees when it comes to text.

comment 14y ago · link · parent

For those wondering what SP-GiST is: it allows the creation of new kinds of specialized non-btree indexes. 9.2 comes with spgist suffix trees over text and spgist quad trees over points.

comment 14y ago · link · parent

"To access an element in an array"

I guess that's the thing: why would you want to access array elements? What business problem is that solving?

"there is a condition there if you want to reference by index which is the primary point of arrays"

In this example, he's using an array more like a set. I don't think he intends for a tag at index 17 to mean something different than a tag of the same value at index 3.

I agree that postgresql should probably have a good "set" datatype, but at this time it does not and arrays are a reasonable way to implement sets in a lot of cases.

For instance, GIN allows fast searches on queries like "find the arrays that contain element 'X'". That's more like a set operation.

"The optimiser will most likely be better at retrieving and caching data based on a join condition versus column contents."

There are probably some cases where it's better and some where it's worse. Postgres does keep track of stats for array elements in addition to the arrays themselves, so it's not obvious to me that using a separate table would improve matters.

comment 14y ago · link · parent

"One of the conditions of the 1NF is that each row and column contain one and only one value."

There is no useful differentiation between atomic and non-atomic values. A timestamp is made up of a date and a time, a string is an array of characters, a real number has a sign and magnitude, etc.

I suppose you could just use boolean only, which could be regarded as "atomic".

comment 14y ago · link · parent

"The key difference is that the components of a complex data type don't stand on their own, or it's a violation of 1NF."

The characters or substrings that make up a string stand on their own. In fact, it's pretty hard to differentiate a string from an array of characters.

Similarly, the date component of a timestamp stands on its own, and timestamps are routinely broken up in that fashion.

"The interesting thing about arrays is depending on the work you're doing with them, they could either be a violation of 1NF or not."

In other words, you're saying that queries are a violation of 1NF, rather than the schema?

What about integers and modulo division? Is modulo division considered to be accessing a component of an integer?

"people reading are developers and will take this as carte blanch to store repeated values or sets as arrays"

There's no substitute for careful thought when designing a schema.

"Intuitions about database storage and performance tend to be incorrect."

Good point.

"loss of relational correctness"

I still don't think you've justified this. Remember that the normal forms are formally defined, so you should be able to show a clear distinction, which I've not seen yet.

"All optimizations are trading flexibility for performance."

What particular kind of flexibility is lost in this example (product tags)?

"The rule of thumb on arrays is don't use them, and there are good reasons for that."

This really sums up the situation. It's easy to use arrays for the wrong things, so the rule of thumb is to never use them. But they are still useful often enough for developers to get frustrated, and the rule of thumb may cause them to invent a worse solution elsewhere.

We should make the good reasons known, rather than just the rule of thumb.

comment 14y ago · link · parent

"can readily turn operations"

Which operations, specifically? We have the product tags example to work from, so it would help to be more concrete.

"into O(M*N) rather than O(N)"

I assume here that your target is "scalability to higher numbers of tags for a given product"? If so, please state that explicitly. Again, M and N aren't necessary, because we have an example to work from.

Are the operations still susceptible to worse scalability on this axis if you employ a GIN index?

"PgSQL documentation suggests cases that will hurt you."

Please elaborate.

"I would suggest that the relational model is maintained"

I don't see how your solution is relational and the other one is not. Can you please explain? How is using an array different from using, say, a string, which is essentially an array of characters? How is it different from using a date, the components of which you can access (e.g. grouping by the month)?

"the optimiser is likely to come up with a better solution."

Please elaborate.

comment 14y ago · link · parent

"The more you put in the database black box, the more scalability problems you will encounter in the future."

I don't see a obvious relationship between using arrays to store product tags and scalability.

What method of solving this problem are you suggesting, and what are the scalability characteristics of that solution?

Databases don't go out of their way to hurt scalability. Databases are shared state, and scaling that is just hard. Unless the problem is easy, in which case it's easy no matter what you use.

comment 14y ago · link · parent

"Arrays aren't really in the spirit of relational design."

Why do you say that? To a certain extent I agree in broad terms; but I don't believe that it is somehow "unclean" or un-relational just because you are using an array (or any other complex data type).

"This means that using them will change the ACID characteristics compared to a relational design."

No, arrays are protected by ACID as is any other data in postgres.

"it would seem like adding another item to a purchase would cause the entire purchase row to lock"

It will still allow concurrent reads of the row in postgres (MVCC). In order for the write lock to be a practical problem, there would have to be a lot of concurrent updates to the very same purchase.

I think we can all agree that the first example is "hacky" (which the author says in the article), so let's ignore that one. How about the second example? I think it's pretty reasonable to store tags that way, if for no other reason than it could save a lot of space.

comment 14y ago · link · parent

One of the differences with postgres is that it's OK to use interesting data types. Other systems treat it as though it were somehow wrong.

See my post here: http://thoughts.davisjeff.com/2009/09/30/choosing-data-types...

And no, using arrays is not an automatic violation of first normal form.

comment 14y ago · link · parent

I'm having trouble finding support for your assertion.

Some quick googling seems to indicate that France has a higher unemployment rate than the US and lower GDP per capita. Same for Spain. Same for the EU overall.

The Netherlands seems to be in better shape but it's a much smaller economy, so it's not really comparable.

comment 14y ago · link · parent

I think the main point is that MariaDB is a better MySQL than PostgreSQL ever will be. I don't see what anyone is gaining by turning postgres into yet another mysql.

Postgres is doing great being postgres. To the extent postgres can accommodate converts from mysql, or oracle or sql server, then also great. But we're too busy inventing new stuff to endlessly chase the quirks of other systems.

comment 14y ago · link · parent

"They are both SQL, it's just a small amount of extra syntax"

I suspect more than a few syntax adjustments would be required before users could rely on the port. The upstream project (e.g. wordpress) would need to be aware that their users were trying to use postgres in order for such users to be actually happy.

I could be wrong, but I have not seen a port of a real app that came down to just syntax differences.

It might be a different story between two implementations that follow the SQL standard reasonably well (MySQL is pretty far from the standard in many ways), but even in that case I'd be cautious.

comment 14y ago · link · parent

"MySQL lost a ton of momentum because of Oracle"

Aside: why, oh why, did 3 mysql forks appear when MySQL AB was bought? Couldn't they coalesce around one alternative?

Ordinarily, I'm not against a little healthy competition. I think forks and trying new ideas is great. But the timing just makes no sense to me from any rational point of view.

"I suspect keeping up with it does not require as much effort as it did getting to where it is now... maybe... it will continue evolving."

True, but I'd hate to see the bar set that low.

comment 14y ago · link · parent

"A MySQL compatibility mode for PostgeSQL would be awesome!"

I think it can be good to offer a few conveniences to make it easier to switch, but I think they should be limited in scope.

Postgresql is not trying to be mysql -- that need is already filled by MariaDB and others. Trying to pretend that postgres is mysql would just make users frustrated and disappointed.

Think about it like moving to a foreign country. The residents try to be as friendly and accommodating as they can when it comes to food, shelter, transportation, directions, etc. There are often even multi-lingual people in the critical places. But eventually the goal is to adapt to the local culture and bring a hint of your previous culture into the mix; not completely recreate your culture in a new place.

comment 14y ago · link · parent

"I guess we can agree based on the outcome that it turned out to be one?"

Agreed. My perception is more that it is turning out to be one and that is a good thing.

"But I do know that in the end, MySQL was open where it really mattered."

The GPL means that there's no real fear that licenses will be scarce. And the large user community means that there will always be people to offer basic support (free or paid) and consulting. To that extent, I agree.

As far as getting bugs fixed, adapting to new use cases and changes in the market, or just moving the product further, the jury is still out. Will Oracle do it? Can any of the forks do it?

Or the larger question: are you OK with calling MySQL, as a product (i.e. the engine), "done"? I'm not saying that in a negative way. We rarely talk about software that's done, or what it would take to finish a given product, or how much sense being "done" even makes.

"It seems in most cases you simply have a core group of developers doing their thing, with occasional discussions and input from the outside."

That's not how I would describe postgresql. There are lots of people that only occasionally submit patches and lots of people that take part in design discussions even if they never submit much code. It's pretty easy to start out as an application developer and then be sucked into a design discussion, and before you know it you are criticizing a design because it doesn't fit your needs.

Even if nobody has ever seen you before, if you jump into a design discussion and have a legitimate concern or use case that hasn't been considered then it will be taken as seriously as any developer.

"What I care about is software quality and proper documentation, those are not necessarily a function of community."

Absolutely correct. Although those things are also not a function of being open source or free of charge.

comment 14y ago · link · parent

Background: I am a postgresql user and developer. I started with MySQL around '99, used both for a while, and then gave up on mysql and haven't really used it since 2007.

I do agree that injecting postgresql into every discussion without adding anything new is getting excessive. And declaring mysql dead is clearly premature. But let me respond to this particular point:

"Show some solidarity with a fellow open source project!"

I guess I never really saw MySQL as an open project.

* when I first started using mysql it was not under the GPL, it was under some free-for-non-commercial use license * They pretty much reject the standards completely (introducing nonstandard things like backticks that make migration away from mysql harder for no apparent benefit) * mysql never fostered an outside developer community (by which I mean people developing mysql itself) * the code is messy and poorly structured * the development ecosystem, like revision control and documentation (and now tests) don't seem to be open * the licensing of the client library is restrictive * they require copyright assignment (although not all of the forks do)

I hope one of the forks does manage to foster a more open community, but communities aren't built overnight nor are they transplanted easily.

comment 14y ago · link · parent

"All that is lost is the MySQL name and brand."

I respectfully disagree.

Building a community of database developers is no small task. PostgreSQL has spent a long time fostering a diverse group of developers, maintaining a clean codebase and infrastructure, and having explicit policies and procedures in place that make it easier for new developers to get started.

That has never been true for MySQL. Development happens largely because of the money that MySQL AB, then Sun, and now Oracle is paying.

Monty is trying to change that with MariaDB (I don't know as much about the others) and I respect that and I hope he succeeds. But it takes a while to go from corporate development to community development successfully -- it doesn't happen overnight, especially in a field like databases where it can be hard to find developers regardless of money.

comment 14y ago · link · parent

A lot of features have been driven by users saying that postgres needs to solve something. Replication in core is the most obvious case. Index-only scans are another example. If you want a zillion more, read old tech discussion about postgres and see how many of those issues have been fixed.

I'll tell you two things that MySQL does right that postgresql doesn't: checksums and ON DUPLICATE KEY UPDATE.

comment 14y ago · link · parent

People avoid introducing new data stores because it adds complexity and it's harder to do queries across data sets. Jamming different data models together in one system is a very viable strategy.

Postgres supports functional indexes, so indexing individual fields within a JSON document is already possible. If it's not easy now it will be easy soon.

Remember XML databases? They became extremely marginalized when relational systems started adding basic support.

comment 14y ago · link · parent

Regarding installation and ease of use, can you be more specific? I see this complaint frequently but, as a postgresql user, it's hard for me to see where the difficulty for new users is and what should be done about it.

comment 14y ago · link · parent

Let's keep this on topic: in what specific ways has postgresql been more open, and how does that lead to a better developer community and greater value for users?

I happen to think the postgres docs are great, and they are open and free unlike the MySQL docs. I have tried following one MySQL doc, only to see it change later and have no way to see the old version. Not a problem for postgres.

If you have some suggestions for the docs please submit them to the docs mailing list.

Postgres also has 15+ years of history in git, which is extremely helpful.

Honestly, I don't know where to start. Postgres is an open community project to the core and benefits from that in so many ways.

comment 14y ago · link · parent

I think it's a bad idea to evaluate by checklists of features you think you need. It's kind of like choosing where to live based on a checklist.

I started with MySQL, then used MySQL and PostgreSQL for a while. Then, when I started to do more "real" projects, I just got so frustrated with MySQL in so many ways at once. It wasn't that MySQL couldn't do it, it's that it was frustrating at every turn.

In my case, what caused me to drop MySQL almost entirely (around 2003 or 2004) was doing a few simple reports involving dates. Then I started using postgres and it was refreshingly consistent and flexible without so many caveats. And now I develop for postgresql, and the code is similarly consistent and flexible (and just all-around nice).

I have had a long string of positive experiences with postgres. It's hard to wrap them up into a feature checklist.

If something held you back from using postgres in the past, it's a good idea to watch the release notes to see if something new might solve that problem (or better yet, discuss on the lists so maybe it will be solved faster). But I tend to think that looking at long lists of features is a distraction.

comment 14y ago · link · parent

* Reliable pickup in about 10 minutes by hitting a button on your phone or a text with your address -- no need to call or tell someone the address. If you've ever had the experience of waiting 30-45 minutes for a cab to ride a couple miles, or maybe the phone line is just busy, you'll know why reliability is important.

* Clean car with friendly and helpful driver (who you can rate). Seems minor, but it opens up possibilities. If you're on a date or business meeting, and for whatever reason need a ride somewhere (e.g. after drinking), uber will enhance the experience rather than cheapening it.

* No money changes hands (taken from your card on file at uber, including tip). Receipt with lots of details (including your route on a map) is emailed immediately.

* I'm pretty sure it's cheaper if you are above $15 fare, or about the same maybe.

I don't have any affiliation with uber, but I have had a great experience so far (only twice, once for me and once for someone else). I plan to use it a little more often.

I guess, in retrospect, I could probably have been happy using cabs more instead; but they just always seemed more awkward, unreliable, and just less pleasant. If I can get this for the same price, why not?

Cabs might still be better for areas where they are easy to get and you're going short distances, e.g. Manhattan or Las Vegas.

comment 14y ago · link · parent

"I suspect it may be possible to create a nefarious drop-in replacement Uber Driver app which reports longer rides."

If you take an uber ride, you receive an email receipt (which you can see on the website too). It shows you exact pickup time, exact duration, total charged, and the route superimposed on a map.

If you think something is awry, they offer a button to request a "fare review".

It's hard for me to imagine how either the driver or uber could cheat the system without a high risk of being caught (way too high to be worth it).

I am more concerned about various bad practices by taxis than uber.

comment 14y ago · link · parent

I got an email showing the route superimposed on a map. The picture I saw was almost an exactly straight line from pickup to dropoff.

If the driver was cheating, then the email would show the wrong route and it would be obvious to me: "hey, I wasn't picked up there" or "that's an inefficient route". I suppose the driver could cheat by small amounts with the duration, but that would be a pretty dangerous game to play because it's so easy to be caught (the exact pickup and duration are also reported) and relatively hard to do (if you hack your phone, it's kind of hard to just say you made a mistake).

If uber was cheating, perhaps it would be more subtle, but it's still verifiable. They'd have to show you a 5 mile route and then say it was 7 miles or something. The danger of being caught for that is way too high to be worth it.

I am more concerned with taxis, honestly. They can take you for a long ride and it's hard for you to tell them otherwise. If you do they can claim "oh, there was construction over there" or "oh, I thought you said XYZ lane not XYZ street". Or, if you ask to be taken to a train station, they can pressure you to take the taxi to your final destination rather than the train (which can be quite intimidating in some circumstances).

comment 14y ago · link · parent

Capitalism is about transferable private property rights. In order to be transferable, they need to be enforced somewhat evenly.

Libertarianism is a different concept that includes economic policies and non-economic policies.

comment 14y ago · link · parent

I often think about software development in similar terms -- evolution versus intelligent design.

The weakness of evolution is that it takes millions of years, it's heavily dependent on initial conditions, there's lots of collateral damage, and most lines die out.

The weakness of intelligent design is that we're only so intelligent, which places a pretty low limit on the possible achievement. (And intelligence is generally regarded as close to a normal distribution, meaning that the smartest people can only handle a small multiple of the complexity of the average person).

Obviously, evolution and design need to be combined somewhat. The question is: how much of each, and at what times during a project? Do you spend 10% of the time quietly planning, 10% arguing with a small group of designers, and 80% trying things and trying to get feedback? Or is it more like 40%, 40%, and 20%? And how do you mix trying things with the designing things?

comment 14y ago · link · parent

"Crony Capitalism"

Which is an oxymoron; government favoritism is the antithesis of capitalism. The fact that money is involved doesn't make it capitalism.

1
777879
87