Postgresql: split database between different machines - postgresql

I want to partition a very large PostgreSQL 8.3 database. Quoting the manual,
Partitioning can provide several
benefits:
...
Seldom-used data can be
migrated to cheaper and slower storage
media.
What's the right way to relocate tables to another media or computer?
Adam

What you are talking about is commonly referred to as Replication or Clustering, depending on how the system is set up.
What you want to do specifically is clustering, and you can do it on PostgreSQL.
The wiki lists some of the existing solutions:
Greenplum Database (formerly Bizgres MPP), proprietary. Not so much a replication solution as a way to parallelize queries, and targeted at the data warehousing crowd. Similar to ExtenDB, but tightly integrated with PostgreSQL.
GridSQL for EnterpriseDB Advanced Server (formerly ExtenDB)
sequoia (jdbc, formerly known as c-jdbc)
PL/Proxy - database partitioning system implemented as PL language.
HadoopDB - A MapReduce layer put in front of a cluster of postgres back end servers. Shared-nothing clustering.

Related

Greenplum selection criteria

I'm getting familiar with the greenplum solution concepts, and trying to understand whether, and if so, when the organisation I work for should use this solution. Our conceptual idea is to setup a kind of central 'datastore' suitable for both OLTP and OLAP access.
My research: this article suggests Greenplum is more suitable for OLAP, and PostgreSQL for OLTP. But I also read about Greenplum improvements for OLTP processing. And in favour of Postgresql, there are also articles like this that suggest that OLAP (eg, a datawarehouse implementation) can be done by means of Postgresql.
So my question is: how to move forward, and what are the main criteria to decide? For example, in case we now have a just a few TB's (1-5), start with a Postgresql cluster (for OLTP+OLAP), and when data volumes grow, move on to Greenplum? Or start straight away with Greenplum?
maybe use postgres if it can handle your use case. If you have you have too much data and need to finish reports and analytics faster; change to greenplum

Data mining with postgres in production environment - is there a better way?

There is a web application which is running for a years and during its life time the application has gathered a lot of user data. Data is stored in relational DB (postgres). Not all of this data is needed to run application (to do the business). However form time to time business people ask me to provide reports of this data data. And this causes some problems:
sometimes these SQL queries are long running
quires are executed against production DB (not cool)
not so easy to deliver reports on weekly or monthly base
some parts of data is stored in way which is not suitable for such
querying (queries are inefficient)
My idea (note that I am a developer not the data mining specialist) how to improve this whole process of delivering reports is:
create separate DB which regularly is update with production data
optimize how data is stored
create a dashboard to present reports
Question: But is there a better way? Is there another DB which better fits for such data analysis? Or should I look into modern data mining tools?
Thanks!
Do you really do data mining (as in: classification, clustering, anomaly detection), or is "data mining" for you any reporting on the data? In the latter case, all the "modern data mining tools" will disappoint you, because they serve a different purpose.
Have you used the indexing functionality of Postgres well? Your scenario sounds as if selection and aggregation are most of the work, and SQL databases are excellent for this - if well designed.
For example, materialized views and triggers can be used to process data into a scheme more usable for your reporting.
There are a thousand ways to approach this issue but I think that the path of least resistance for you would be postgres replication. Check out this Postgres replication tutorial for a quick, proof-of-concept. (There are many hits when you Google for postgres replication and that link is just one of them.) Here is a link documenting streaming replication from the PostgreSQL site's wiki.
I am suggesting this because it meets all of your criteria and also stays withing the bounds of the technology you're familiar with. The only learning curve would be the replication part.
Replication solves your issue because it would create a second database which would effectively become your "read-only" db which would be updated via the replication process. You would keep the schema the same but your indexing could be altered and reports/dashboards customized. This is the database you would query. Your main database would be your transactional database which serves the users and the replicated database would serve the stakeholders.
This is a wide topic, so please do your diligence and research it. But it's also something that can work for you and can be quickly turned around.
If you really want try Data Mining with PostgreSQL there are some tools which can be used.
The very simple way is KNIME. It is easy to install. It has full featured Data Mining tools. You can access your data directly from database, process and save it back to database.
Hardcore way is MADLib. It installs Data Mining functions in Python and C directly in Postgres so you can mine with SQL queries.
Both projects are stable enough to try it.
For reporting, we use non-transactional (read only) database. We don't care about normalization. If I were you, I would use another database for reporting. I will desing the tables following OLAP principals, (star schema, snow flake), and use an ETL tool to dump the data periodically (may be weekly) to the read only database to start creating reports.
Reports are used for decision support, so they don't have to be in realtime, and usually don't have to be current. In other words it is acceptable to create report up to last week or last month.

Does PostgreSQL support Active-Active Clustering with DRBD?

We use PostgreSQL 9.3 in our application. We want to setup PostgreSQL active-active clustering with DRBD. I google it and see a lot of resource about active-passive.
Does PostgreSQL support Active-Active Clustering with DRBD?
No, PostgreSQL does not support active/active clustering with DRBD.
PostgreSQL does not support any form of shared-storage clustering in any way - active/active, active/passive, or otherwise.
It's rather implausible to support shared storage clustering with the architecture in PostgreSQL. Lots of things would need to change. In particular, Pg couldn't lazily write buffers to disk anymore, which would be brutal for performance.
You'll need to use replication. You can use read-replicas (with a few limitations) that way.
There's no support for multi-master, nor is there any support for auto-relaying write queries to the master from a replica. Some people use PgPool-II for routing queries, though it also has some significant limitations.
(I'm involved in work on bi-directional replication, which seeks to offer another alternative, but it's very much alpha. See BDR on the PostgreSQL wiki)

How can one replicate a graph database like Neo4J

I am noob in NoSQL world. but After going thru the basics of how Neo4J works, I didnt unerstand how will replication be fast compared to column or document databases or a plain key value DB.
It has nodes and edges which are nothing but relations between those nodes, something simiar to Joins in a RDBMS.
So how does replication works here as ccompared to an RDBMS ?
Each NoSQL database will behave in different ways when it comes to replication. NoSQL is quite a wide term, so you should not expect to have good replication performance for all of them. In fact Neo4j Enterprise has some support for replication, but the design of Neo4j does not naturally lead to scaling. It is certainly not of of the core objectives, unlike others like Cassandra for example.
What do you mean with replication? Neo4j enterprise comes with an high-availability cluster that replicates your data across a number of machines.
If it is just about replicating the data, you can also shutdown your database and copy the database files (or in enterprise execute a online backup).

Postgresql for OLAP

Does anyone have experience of using PostgreSQL for an OLAP setup, using cubes against the database etc. Having come across a number of idiosyncracies when using MySQL for OLAP, are there reasons in favour of using PostgreSQL instead (assuming that I want to go the open source route)?
There are a number of data warehousing software vendors that are based on Postgresql (and contribute OLAP related changes back to core fairly regularly). Check out https://greenplum.org/. You'll find that PG works a lot better (for nearly any workload, OLAP especially) than MySQL. Greenplum and other similar solutions should work a bit better than PG depending on your data sets and use cases.
PGSQL is much better suited for Data Warehousing compared to MySQL. We had thought initially to go with MySQL, but it performs poorly in aggregations if data grows to a few million rows. PGSQL performs almost 20 times faster in caparison with MySQL for 20 million records for a single fact table on same hardware setup. If for some reason you choose to go with MySQL, then you should use MyISAM storage engine for fact tables rather then InnoDB; you will see slightly better performance.