TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Standard SQL features where PostgreSQL beats its competitors

96 pointsby MarkusWinandover 7 years ago

6 comments

orfover 7 years ago
The first feature in the deck is FILTER, which I can&#x27;t help but mention I added support for (with a case&#x2F;when fallback) to Django 2.0. So, if you&#x27;re using the new Django release you can use this syntax on any aggregate&#x2F;annotate via the filter kwarg[1] now.<p>There was one user report on the github PR that said FILTER was 10-15% faster over the equivalent CASE&#x2F;WHEN, due to the null filtering I think. It&#x27;s a shame only Postgres supports this supposedly standard syntax.<p>Edit: Heh, I initially got (stole) the idea of using FILTER + CASE from modern-sql.com[2], which is run by the author of this slide deck. So I guess I aught to thank Markus for this!<p>1. <a href="https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;2.0&#x2F;ref&#x2F;models&#x2F;conditional-expressions&#x2F;#conditional-aggregation" rel="nofollow">https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;2.0&#x2F;ref&#x2F;models&#x2F;conditional...</a><p>2. <a href="http:&#x2F;&#x2F;modern-sql.com&#x2F;feature&#x2F;filter" rel="nofollow">http:&#x2F;&#x2F;modern-sql.com&#x2F;feature&#x2F;filter</a>
评论 #16299844 未加载
评论 #16299475 未加载
combatentropyover 7 years ago
I learned a few things, despite having used Postgres for many years: (1) the filter clause with aggregates to more succinctly pivot tables, (2) the not-valid clause with check constraints to apply only to new data while leaving old rows alone, and (3) something about inverse-distribution functions --- I actually didn&#x27;t learn these yet but bookmarked it for later, because it&#x27;s too hard to read on a Saturday ;)<p>It really is amazing how much you can prepare your data before it leaves your database, or how raw you can leave your data before sending it there, letting Postgres take care of it. I wonder how much middle code would be saved (PHP, Python, Perl, etc.) if more programmers knew more SQL, and especially if they chose Postgres more often. I also wonder why SQL seems to be the language that developers know least, even though it seems like it should be easiest, with its declarative, natural-sounding syntax. (I admit that the naturalness is deceptive. Just because &quot;select color, count(1) from favorites where age &lt; 13 having count(1) &gt; 3 order by 1&quot; sounds like English doesn&#x27;t mean you can tell exactly what it will do before reading the manual.)
评论 #16299997 未加载
zkompover 7 years ago
It was a good talk at fosdempgday. Well paced, funny at times, esp the part comparing booleans with mysql &quot;booleans&quot; and &quot;check constraints&quot; (spoiler neither boolean nor checked)<p>Too bad I&#x27;m stuck on 9.1 for the time being which lack many of these really nice features.
评论 #16299404 未加载
minimaxirover 7 years ago
It might be worthwhile to add cloud data warehouses with SQL interfaces (e.g. Redshift&#x2F;BigQuery) to the slides, as I believe they have a similar feature set to PostgreSQL.
评论 #16299392 未加载
craigkerstiensover 7 years ago
Postgres isn&#x27;t always perfect and for a few things lagged behind for a few years (namely upsert and better replication support). Fortunately we got both of these in recent releases, but this post is a great collection of areas where it already shined with some powerful features.<p>In particular really love the details on check constraints and null in Postgres.
mjw1007over 7 years ago
Some of the information looks off. The chart shows CHECK constraints appearing in PostgreSQL in 8.3, but they&#x27;ve been there since at least 7.1.
评论 #16299472 未加载