Instead of running PostgreSQL server locally (or on your testing machine), maintaining the server, credentials, etc… postgression instantly provisions a new PostgreSQL database for your application to run tests against: for free!
My experience with MongoDB
For starters, while a schemaless solution makes early tinkering more frictionless, sometimes you want the checks and data protection that a schema can provide. Typed columns also allows relational databases to make optimizations that MongoDB can’t.
.. The docs suggest running it on at least three dedicated servers with ample resources each. This was a bit much for me so I ran it on a single server which it shared with the application. As a result my application was slow and the server crashed periodically. Now you could criticize me for not following the recommended procedure, and you’d be right, but understand that when I switched to PostgreSQL, without increasing the hardware capacity at all, all of my performance and stability problems went away. MongoDB demanded too much for less performance and essentially the same queries
.. Besides, unless your system is particularly write heavy relational databases can use replication to scale out anyhow. MongoDB’s model really isn’t an advantage unless you are solving a write-heavy, Big Data problem.1 Until you reach that scale, it’s actually slower than the alternative.
Indiscriminate use of CTEs considered harmful
However, there is one aspect of the current implementation of CTEs that should make you pause. Currently CTEs are in effect materialized before they can be used. That is, Postgres runs the query and stashes the data in a temporary store before it can be used in the larger query. There are a number of consequences of this.
.. After some analysis and testing, the simple act of inlining two CTEs in the query in question resulted in the query running in 4% of the time it had previously taken. Indiscriminate use of CTEs had made the performance of this query 25 times worse.
Creating Pivot Tables in PostgreSQL Using the Crosstab Function
SELECT
*
FROM
crosstab(
'select extract(month from period)::text, subject.name,
trunc(avg(evaluation_result),2)
from evaluation, subject
where evaluation.subject_id = subject.subject_id and student_id = 1
group by 1,2 order by 1,2'
)
AS
final_result(
Month
TEXT, Geography
NUMERIC
,History
NUMERIC
,Language
NUMERIC
,Maths
NUMERIC
,Music
NUMERIC
);