
“Fashion Is Hard. PostgreSQL Is Easy” [video] - nickdotmulder
https://tech.zalando.com/blog/watch-fashion-is-hard-postgresql-is-easy/
======
StavrosK
PosgreSQL is pretty much my default. Any other database has to have compelling
arguments for how it fits my use case if I'm going to use it over Postgres,
and even then, it usually gets used for a subset of the data, while Postgres
gets everything else.

I think it's better to default to the tried-and-true piece of software than
the new and shiny, rather than the other way around and have to argue why
Postgres is a good fit for your data.

~~~
brightball
That's probably the best way of looking at it. PostgreSQL is generally going
to be the best solution for 90% of your data, short of having a subset that's
write heavy to the point of streaming.

~~~
escherize
What is a good space to look at when you get write heavy data to the point of
streaming?

~~~
marcosdumay
The filesystem.

Ok, that not completely serious, but almost completely.

~~~
spacecowboy_lon
Could work dump the incoming steam to disk in some sensibel text format and
have an asynchronous queue process the data into the database.

~~~
neeleshs
At that point may be something like Kafka starts looking attractive

------
tempodox
That title is really great, and also rings true. And of all open-source SQL
DBs, PostgreSQL is superbly executed and a breeze to work with. I can only
recommend it.

~~~
lmm
As someone who's used to MySQL, I keep trying to use PostgreSQL (better
standards compliance, better behaviour in the face of bad data) - and I keep
going back. The psql interface is awkward (too many magic backslash commands
to memorize instead of SHOW CREATE TABLE) and always feels slightly laggy
somehow.

~~~
ibotty
You are the first person I read saying they like the mysql cli. Ctrl-c kills
the whole shell. great, but not what I expect. Want to fix a small typo in
your big query? In psql you can just edit your last command in your $EDITOR.
Useful (but not perfect) autocomplete is also not in mysql.

~~~
mdemare
> In psql you can just edit your last command in your $EDITOR.

Cool! How?

~~~
masklinn
`\e` will edit whatever is in the query buffer (`\p` shows the content of the
query buffer)

------
emilburzo
I love PostgreSQL.

But for a personal project I went with MongoDB, because my data set was a
perfect match for mongo's design.

Now I love mongo too, I'm amazed with how easy it has been to maintain 100%
uptime on comodity hardware (one server is literally in a room in my
apartment) through all the random server downtimes, upgrades, migrations, etc.

And now I have more ideas for some personal projects, and they would go very
well with postgres, but I'm so missing replica sets from mongo.

If postgres would have something similar to replica sets in mongodb, that
would be amazing.

~~~
sandGorgon
do take a look if you can leverage jsonb datastructure of postgres - you get
80% of the power of mongo and all the advantages of postgres.

[https://www.compose.io/articles/is-postgresql-your-next-
json...](https://www.compose.io/articles/is-postgresql-your-next-json-
database/)

~~~
ma2rten
Actually the article you posted makes the case that postgres is not a good
json database, because it can not modify json documents in place.

~~~
neilc
PG 9.5 will improve this situation somewhat, e.g., builtin functions like
jsonb_set(), and overloading the '-' operator for jsonb values:

[http://www.postgresql.org/docs/devel/static/functions-
json.h...](http://www.postgresql.org/docs/devel/static/functions-json.html)

That said, if you're doing a lot of mutation of large JSON documents stored in
a single Postgres row value, the storage/concurrency control behavior still
won't be ideal.

~~~
valgog
Actually if you really need to update large JSON documents efficiently,
probably the only really efficient technology would be ToroDB
[http://www.8kdata.com/torodb/](http://www.8kdata.com/torodb/)

~~~
themartorana
I would love to hear more - this is the first I'm hearing of Toro - it never
comes up in NoSQL talks or conversations. Any decent success stories?

------
mhd
I had a job interview at Zalando a while ago, and apart from the huge bunch of
bananas at the entrance to the developer's den, the one thing I remember most
about was the fact that apparently they're using stored procedures for
basically any database transaction.

Which is probably a more unorthodox use of databases these days, at least for
Postgres (I've heard it was more common for SQL Server and I once had the
questionable joy of debugging a petri net solver in Oracle).

~~~
dragonwriter
"Stored procedures for everything" is a bit unorthodox, but its probably a
better practice that "base tables for everything" (which seems to be the
common trend these days), and is pretty much the closest real practice to the
"views for everything" that was long the ideal for decoupling decoupling the
interface that each component using the DB saw from the underlying data model
(an ideal that was, when it was made, often unachievable because of each RDBMS
had different limitations on what you could do with views, particularly on the
update side.)

Though, with modern PostgreSQL, views-for-everything would probably work at
least as well as stored-procs-for-everything.

~~~
ams6110
I don't think it's unorthodox. Perhaps uncommon these days. The application
logic needs to live somewhere. I like doing in stored procedures because you
are close to the data and that leaves your client code free to just implement
the user interface. It's much easier to support different client platforms
without having to rewrite all your core transactions. It's actually my
favorite way to architect an application. I like views for the same reason,
especially for use with 3rd party reporting/BI tools.

------
fideloper
PostgreSQL is great, but I've gone back to MySQL because of the ease of which
I can setup replication (which I like to use when possible in addition to
automated/periodic backups).

~~~
angrybits
RDS makes it trivial to have high availability if you can't afford a DBA worth
their salt. You don't need 10x replication to beat the uptime of your shitty
web app.

~~~
takeda
I thought so too, until I decided to use RDS for storing zabbix.

It looks great on paper, but unless you're doing development I would
discourage its use. That said your original point about the replication is
true, but there are shortcomings that come together with it.

Some things that you will learn if you use RDS:

\- if you decide to increase volume size, change type to SSD or use
provisioned IOPS, you might have database down for an hour or more. Regardless
whether you use single instance or HA.

\- want to upgrade 9.3.x to 9.4.x? Tough luck you have stop dump the data and
provision a new instance. You can't use postgres' inplace upgrade method

\- you have limited control regarding tuning, many settings require rebooting
the whole thing, when normally you would just restart the process (with HA
there's still several seconds of interruption)

\- you can only use extensions that they provide, there's almost no extension
to monitor performance

\- you can't login to use shell to monitor the process (obviously, but it's a
still shortcoming)

\- can't replicate data across regions or outside of RDS (it could resolve
some of the issues above)

\- it can fail, we had two times a failure caused by AWS, it happened during
backup period. Normally AWS does backup on the secondary database, but we
learned that in those instances it got confused and was attempting to do it on
primary, rebooted it and for about 15 min the database was unavailable.

~~~
angrybits
First off, thanks for sharing your experiences. I am standing up a system
right now that will use PostgreSQL RDS and it's good to know what kinds of
bumps in the road to expect.

I think I am fine with most of those, since I am saving on labor costs.
Periodically taking an app down for maintenance is par for most courses. And
even on the last bullet, I've seen really talented database guys make mistakes
and have small amounts of downtime. Perhaps what I should have said was "high
enough availability". If I needed 5 9's, I agree that RDS is probably not the
tree I want to be barking up.

Cheers!

~~~
takeda
Yeah RDS is ok as long as you are ok with the limitation.

I was more concerned about relying on it for 24/7 operation. Such as for
transactions on a webpage. The zabbix scenario in our case also requires 24/7
uptime, but if it goes down our site is still up we just won't be alerted when
something else breaks at the same time.

------
vassy
Two years ago I switched from PHP and MySQL to Ruby and PostgreSQL. The only
thing I'm missing is Sequel Pro. PG Admin is ok, does everything I need, but
that interface is ugly and unintuitive.

[1] [http://www.sequelpro.com/](http://www.sequelpro.com/)

~~~
lxfontes
Have been using postico
[https://eggerapps.at/postico/](https://eggerapps.at/postico/) for day to day
queries and pgadmin for more hardcore operations

~~~
vassy
It's still beta it seems. I used PG Commander, but it was too basic.

------
UserRights
I found this video to be much more interesting
[https://youtu.be/zsF1vfHBMBI](https://youtu.be/zsF1vfHBMBI)

BTW I would like to send out a BIG THANK YOU to the guys that did the videos -
this is such an important and great service for everybody who could not attend
the conference, so: THANK YOU VERY MUCH!

~~~
valgog
There are definitely a lot of much more interesting videos from PGConf US
2015, especially the one from Robert. My talk was a 'keynote' and not really a
conference talk :)

------
geedy
I recently used Postgres for a serious project for the first time and I am
really impressed. Certainly much more impressed with it than MySQL or SQL
Server. plpgsql is far better than what MySQL offers out of the box, plus you
have access to nicer languages out of the box with plv8, plpythonu, plr, etc.
Language extensions really are a killer feature and make moving application
logic into the database a cinch.

------
ksec
Is there anything on Postgre Roadmap to allow, simple, easy, replication out
of the box?

------
comrade1
Are they using Postgres for content, or for data? (at a place where I can't
really watch a movie)

There are some great content management tools out there, my favorite being
apache jackrabbit, and on top of that, apache sling for displaying/accessing
the content. It requires a different way of thinking than the standard mvc
process - it is a more content focused display process.

I don't know... if you're using Postgres to store non-relational data you may
want to reassess your strategy. You may find you're doing the right thing
still, but I think most people would be better served with a system like
jackrabbit/sling, which is is used by publishers, fashion houses, etc (via
Adobe's product that is built on sling) to store and display their content.

(that said, you can use postgres on the back-end with sling)

~~~
cwyers
> I don't know... if you're using Postgres to store non-relational data you
> may want to reassess your strategy.

What kind of data lacks any relations whatsoever? Yes, there are cases where
fitting data to the relational model is more awkward than others. But I would
be really, really cautious about thinking that I could design on my own a data
model that's better than the relational model. Relational databases are
incredibly battle-tested across every type of data storage problem out there.

~~~
JohnBooty

      > What kind of data lacks any relations whatsoever?
    

You're right: all data has some kind of relation - when we say "non-relational
data" we almost always really mean "loosely related." But some data is much
more strongly related than others.

Think of a traditional RDBMS application such as an ordering system where
there are strong relational constraints that need to be enforced _before_
committing your data: ie, your _order items_ had damn well better correlate
with an _order,_ which damn well better correlate with a _user,_ or else
nothing makes sense -- you had better raise an exception and should definitely
not store those things in your database if the relational integrity is not
there.

Now constrast that with other types of data collection where relational
integrity is much more relaxed.

Generally, these examples would be (near) real time data collection - times
when you're collecting data with a "collect first, analyze/correlate later"
mentality. Specific examples would be a service that aggregates logs from a
server farm in real time, or things like tracking user behavior statistics on
the web. Or even an onboard computer that collects data from a car's engine -
you want to read that data every 50ms no matter what, and maaaaaybe you will
correlate it with events (accidents? combustion issues? whatever) later on
oooooorrrr maybe not.

~~~
cwyers
There are times where you really don't need an RDBMS, yes. Hard real-time
embedded systems are their own bag, I certainly wouldn't want to tell the
people who design the systems inside a car how to do their job. As for server
logs... they're their own bag, too, although if you decide to roll your own
setup there without fully investigating syslog and journald or whatever else,
I think you're probably making a mistake here.

But if you're running a website and you have fewer than 100 servers and you
think you need to start rethinking the entire relational data model, you may
very well be getting ahead of yourself.

------
kriro
Coming up with your own ideas is hard. Cloning other businesses is easy.

~~~
perlgeek
Coming up with ideas is easy. Executing them well is hard.

~~~
kriro
Zalando is hardly executed well. The work conditions in their logistics
centers are (infamously) atrocious. The strategy was distinctly described by
one of the Samwer brothers in email conversation as "Blitzkrieg" and "the most
aggressive plan in history". Work climate (not only for manual labor) reflects
this attitude pretty well.

~~~
MrBuddyCasino
Yes, their website still sucks in the same ways it did 3 years ago. It boggles
the mind.

They have a huge selection, expensive advertising campaigns and lenient
shipping & return policies, fueled by huge sums of money, so they have a huge
market share. Its nice, but execution is merely decent imho.

~~~
crdb
Try a rewrite at a company with more than 100 employees... cf
[http://www.joelonsoftware.com/articles/fog0000000069.html](http://www.joelonsoftware.com/articles/fog0000000069.html)

~~~
MrBuddyCasino
No need to rewrite anything - all they need are a few UI improvements. Its not
like their backend is MongoDB or something. ^_^

------
kaufland
Hmm, looking a bit at their site[1]:

 _Addidas jogging pants -- 59,95 €_

 _Volcom T-shirt print -- 17,45 €_

 _Under Armour T-shirt -- 39.95 €_

Like really now -- who needs this stuff? Especially when you can just go to
Aldi or Tchibo (or any of a number of other discount retailers readily visible
at nearly every shopping mall in Germany) and buy essentially same stuff
(minus the logos, of course) for 1/10th of the price. So perhaps a better
title might be:

 _“Fashion generates revenue, and handsome pay-outs. But is basically
pointless. And a soul-sucking waste of time.”_

[1] [https://www.zalando.de/herren-home/](https://www.zalando.de/herren-home/)

~~~
pavlov
A t-shirt for 1.75 € is so cheap that it's practically guaranteed to have been
manufactured in dangerous conditions in a place like Bangladesh or Ethiopia.

Big brands like Adidas or Under Armour don't have a clean track record either,
but at least they are somewhat accountable to consumers because their #1 asset
is their reputation. To fix global trade, it's better to do a bit of research
into what kind of company you want to support, rather than blindly buying the
cheapest imported thing "because they all suck anyway".

~~~
icebraining
You mean the money is actually going to poor people? Sounds like a plus to me.

~~~
pavlov
Certainly not. The ultra-cheap stuff is cheap throughout the production
pipeline. Costs are cut wherever possible: wages, tools, work environment,
materials, packaging...

The "poor people" won't benefit from most of the branded product's premium, of
course. But it's more likely that it's been produced by a subcontractor that
at least respects local laws like minimum wage, construction standards and
regulations concerning toxic materials.

~~~
icebraining
Being blunt, how do we know? For example, when the buildings collapsed back in
2013, the discount chains selling unbranded clothes like Primark and Loblaw
pledge to offer compensation, while Benneton tried to hide their relationship
with the manufacturer.

As it ever been studied if the work conditions of the workers making branded
stuff are generally better than their counterparts working on cheaper clothes?

