Testing Extensions with GitHub Actions— pgxn-tools provides a Docker image with scripts to install and run any version of Postgres and this can be brought together with a CI/CD platform like GitHub Actions to test Postgres extensions on multiple Postgres versions. David E. Wheeler |
![]() Whitepaper: BDR - Advanced Clustering & Scaling for PostgreSQL— Learn more about Advanced Clustering & Scaling for PostgreSQL with BDR including use cases, architectures, features & benefits. BDR provides multi-master replication with AlwaysOn availability, worldwide clusters, & Cloud Native deployments for PostgreSQL databases. 2ndQuadrant PostgreSQL Products sponsor |
Calculating Differences Between Rows in SQL— If you have lots of rows that represent changing values (such as time series data, say) being able to calculate the differences between the values over time could be useful, here are some approaches. Hans-Jürgen Schönig |
PDF: Running Postgres in Kubernetes— A slidedeck based rundown of the top options for running Postgres in Kubernetes and some of the features contained within each. Lukas Fittl |
On Join Strategies and Performance— It’s worth understanding the three forms of join strategy Postgres uses when joining relations and how you can influence them with indexes. Laurenz Albe |
Can Case Comparison Be Controlled?— “Let’s go over some Postgres case-precision behaviors like the handling of character strings, identifiers, and keywords.” A handy primer to case comparison issues here. Bruce Momjian |
Postgres Anonymization on Demand— If your database stores personally identifiable information – and it probably does! – anonymization can help protect that data while still keeping the database useful. This articles digs into an approach for applying anonymization globally, covering all applications, with minimal code rewrites. Achilleas Mantzios |
supported by ![]() 💡 Tip of the Week Use WITH to query a subset There is a whole lot you can do with Common Table Expressions (CTEs) from traverse trees to using window functions in rankings. CTE functions are implemented by the “WITH” clause. A basic use is to query a subset -- similar to a subquery. Let’s demonstrate this by setting up some sample data: |
CREATE TABLE databases ( name TEXT, model TEXT, type TEXT, pgcompat boolean, opensource boolean);
INSERT INTO databases VALUES ('YugabyteDB', 'rdbms' , 'distributed sql', TRUE, TRUE), ('CockroachDB', 'rdbms', 'distributed sql', FALSE, FALSE), ('MongoDB', 'document', 'nosql', FALSE, FALSE), ('Neo4j', 'graph', 'nosql', TRUE, FALSE), ('Cassandra', 'columnar', 'nosql', FALSE, TRUE);
|
If we wanted to run a query against databases that were open source licensed, support SQL and are compatible with PostgreSQL: |
WITH dbs AS ( SELECT name, model, (CASE WHEN type = 'distributed sql' then TRUE ELSE FALSE END) sql_support, pgcompat, opensource FROM databases
)
SELECT name, model
FROM dbs
WHERE opensource = TRUE, pgcompat = TRUE, sql_support = TRUE
ORDER BY name;
|
We created a CTE called dbs and reinterpreted the “type” field to be sql_support as a boolean using a case statement. In the main select statement we query against this CTE and in our where clause, we are able to specify only booleans. This gets us a result like so: |
name | model
-------------------
YugabyteDB | rdbms
|
This week’s tip is sponsored by YugabyteDB, the high-performance distributed SQL database for internet-scale applications. Serve applications with SQL query flexibility and cloud native agility. |
|
|