News for hackers. Stuff that matters.
Re:Plans for partitioning in PostgreSQL v11 by rorygibson on Tuesday August 15, 2017 @06:08AM (#15016851)
As a long time user of MySQL, I've switched to PostgreSQL for my most recent startup precisely because the PostgreSQL team continue to innovate in a sensible way.

One of the core requirements is a stable, fast and reliable initial import of existing data from 3rd party services, and because of throttling concerns that led us to a batched, retryable solution - and a requirement for simple, fast job control.

We've built this around a parallelised solution using the FOR UPDATE/SKIP LOCKED feature from PostgreSQL 9.5 onwards.

It's not bleeding edge, but for us it was a great example of how the pg team pick up the useful features from e.g. Oracle, and incorporate them into the product in a solid way, without all the enterprisey marketing crap that Oracle make you swallow before you can understand the actual feature-set.

[the startup is a SaaS search tool that helps you index across Trello, email, GitHub, Slack, Drive - https://getctx.io if you're interested.]

Re:Plans for partitioning in PostgreSQL v11 by bpicolo on Tuesday August 15, 2017 @10:05AM (#15018248)
FOR UPDATE ... SKIP LOCKED solved a problem for us recently as well. It's a great feature for an adhoc sort of queue situation without needing a dedicated queue / workers.
Re:Plans for partitioning in PostgreSQL v11 by grogers on Tuesday August 15, 2017 @07:49AM (#15017293)
It might be a good choice to switch to postgres, but it isn't like MySQL isn't innovating too. 8.0 will have a ton of features. This includes a bunch of "catch up" things like CTEs and SKIP LOCKED, but also stuff like synchronous replication built in.
Re:Plans for partitioning in PostgreSQL v11 by jimktrains2 on Tuesday August 15, 2017 @11:08AM (#15018904)
I know the defaults have been changed to be safe, but I will forever feel like my trust was broken with MySQL the day I learned how bad the defaults are. Not just inefficent/generic, but actually bad.

Additionally, I feel that postgresql is better engineered, more featureful, and has support for a much larger variety of use-cases (e.g. hstore, json, postgis, pg-routing, uuids, trigram indecies, &c). So between engineering perks, and the loss of trust, I only use MySQL in legacy applications that I cannot port.

Re:Plans for partitioning in PostgreSQL v11 by rhaas on Tuesday August 15, 2017 @09:54AM (#15018154)
The first release of PostgreSQL that had synchronous replication was released in September 2011.

https://www.postgresql.org/docs/9.1/static/release-9-1.html

Re:Plans for partitioning in PostgreSQL v11 by devj on Tuesday August 15, 2017 @10:43AM (#15018603)
For a product like yours, don't you think a NoSQL solution would be a better fit? If yes, why didn't you opt for it? If no, then why(especially considering the fact that your schemas are always in a state of flux)? PS: This is under the assumption that you have used Postgres for storing all the data from different sources.
Re:Plans for partitioning in PostgreSQL v11 by jimktrains2 on Tuesday August 15, 2017 @11:03AM (#15018850)
Not OP, but having structure to a datastore is important. It decreases development and maintenance time and doesn't let vauge bugs fester for years. NoSQL is a premature optimization that many people make without understanding the downsides.
Re:Plans for partitioning in PostgreSQL v11 by devj on Tuesday August 15, 2017 @11:40AM (#15019226)
Completely agree. But in the above case, the structure of third party service API will always change and each change may require a migration. I worked on a similar problem in my last stint and used Postgres. Here I opted for predefined fields and handled the extra logic in application code. In the above case, I just wanted to know if there is a better way to solve the problem in Postgres.
Re:Plans for partitioning in PostgreSQL v11 by bjt on Tuesday August 15, 2017 @12:33PM (#15019739)
I get a lot of mileage out of using real columns for the data with fixed structure, and Postgres JSONB columns for the parts of the data whose structure varies.
Re:Plans for partitioning in PostgreSQL v11 by rorygibson on Tuesday August 15, 2017 @11:13AM (#15018958)
Hi devj, You're absolutely correct that an RDBMS would be an odd solution for a search index *

Anyway, on CTX I use PostgreSQL for storing things that deserve to be relational - job control, batching, users, accounts, billing, invitation codes...

All the indexed content is in an Elastic Search cluster (http://elastic.co if you're unfamiliar - it's a specialised search indexing data store built atop Apache Lucene)

* though actually PostgreSQL has a really good capability as a JSON store that means people do sometimes use it as a NoSQL solution

Re:Plans for partitioning in PostgreSQL v11 by kuschku on Tuesday August 15, 2017 @11:26AM (#15019102)
PostgreSQL has really good capability not just as JSON store, but also for search and indexing.

Its text search solutions come close to ElasticSearch, with - surprisingly - even better performance.

Re:Plans for partitioning in PostgreSQL v11 by rpedela on Tuesday August 15, 2017 @02:17PM (#15020842)
> Its text search solutions come close to ElasticSearch, with - surprisingly - even better performance.

PG search may be good enough for certain use cases, but it doesn't come close to the power of Lucene/Solr/ES. PG only recently added support for phrase search which Lucene has had for years. Lucene has extremely flexible analysis pipeline, BM25, "more like this" queries, simple custom ranking, great language support, "did you mean?", autocomplete, etc. ES in particular is built from the ground up as a clustered solution.

As I said PG may be good enough for some use cases, but to claim it is as good as ES is laughable. And PG certainly doesn't make sense if your product is literally a search product.

Re:Plans for partitioning in PostgreSQL v11 by kuschku on Tuesday August 15, 2017 @02:37PM (#15021030)
All things you mentioned can be done in PGSQL with similar performance, actually.

I have to build a search product in PGSQL, and I’ve done exactly that (and compared it with ES, Solr and Lucene).

For datasets below 50GB the performance is basically the same, you get about the same features, and it works well enough.

But you are right, as soon as you want to build more complicated search products, or as soon as you get larger amounts of data, you want a dedicated solution.

Re:Plans for partitioning in PostgreSQL v11 by rorygibson on Tuesday August 15, 2017 @11:35AM (#15019188)
tbh I haven't looked into PostgreSQL as a direct competitor to ES in the text search space, mostly because I have quite a lot of ES experience of things like aggregation for faceting, stemming and textual analysis, and I had a (perhaps incorrect) assumption that PostgresSQL was less capable in those more specialised areas.

One thing I would like to understand is how the PostgreSQL search experience scales with data volume. My main cluster for CTX will potentially get (very) big and I don't know enough about PostgreSQL, multi-master and full-text search across large amounts of data.

I'll definitely do some digging though, thanks!

Re:Plans for partitioning in PostgreSQL v11 by anarazel on Tuesday August 15, 2017 @12:17PM (#15019577)
> tbh I haven't looked into PostgreSQL as a direct competitor to ES in the text search space, mostly because I have quite a lot of ES experience of things like aggregation for faceting, stemming and textual analysis, and I had a (perhaps incorrect) assumption that PostgresSQL was less capable in those more specialised areas.

I think your assumption is/was correct. And I'm a postgres dev, so I'm biased as hell...

Re:Plans for partitioning in PostgreSQL v11 by kuschku on Tuesday August 15, 2017 @12:20PM (#15019608)
PostgreSQL is very capable at stemming and textual analysis, but the issue as you likely know starts with large amounts of data – because then you suddenly need multiple replicas, and that’s where the issues start.
Re:Plans for partitioning in PostgreSQL v11 by jacobr1 on Tuesday August 15, 2017 @12:14PM (#15019528)
You might want to look at https://github.com/zombodb/zombodb. It extends PG to use ES as an external source for indexes. So you can do an ES based text search and return a data stored in PG along with doing joins to other tables. Zombo even works with Citus to handle PG level sharding.
Re:Plans for partitioning in PostgreSQL v11 by devj on Tuesday August 15, 2017 @11:45AM (#15019284)
Thanks @rorygibson. Yes, that design will definitely work. Just one doubt: Are you syncing data between ES and PSQL for common entities like users? If yes, how are you doing it?