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.

PostgreSQL Features You May Not Have Tried but Should

255 pointsby _1almost 7 years ago

18 comments

sntranalmost 7 years ago
One of the less-known behaviour (I&#x27;m reluctant to say &quot;features&quot;) is that you can have some sort of virtual field in a table, that will execute a function when the field is accessed. This is due to the logic that PostgreSQL treats `row.property` the same as `property(row)`.<p>For example, we can have the function `full_name(person)` that returns the concatenation of `person.first_name` and `person.last_name`, and we can do `SELECT p.full_name FROM person p`. I think it&#x27;s pretty neat.
评论 #17359114 未加载
评论 #17362376 未加载
评论 #17358782 未加载
评论 #17358624 未加载
Mister_Snugglesalmost 7 years ago
One feature that&#x27;s incredibly useful, but not on this list, is the JSON support[0]. Being able to store schemaless documents alongside your structured data is very handy in some instances. Being able to query the JSON documents in a useful manner is also incredible.<p>[0] <a href="https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;10&#x2F;static&#x2F;datatype-json.html" rel="nofollow">https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;10&#x2F;static&#x2F;datatype-json.html</a>
评论 #17357721 未加载
评论 #17359364 未加载
krylonalmost 7 years ago
Posts like this always make a little sad, because at work, we use Microsoft SQL Server[0], and for private programming, I usually prefer SQLite. Still, in some ways, Postgres feels like somebody invented a time machine and brought back a database engine from the future. <i>Sigh</i> Maybe I will find a good reason to use Postgres one of these days... ;-)<p>[0] Do not get me wrong - if you can ignore the price tag, MSSQL is a great database engine. It has never given me any trouble I have not asked for, and it has some very nice features of its own (e.g. the Service Broker).
评论 #17358688 未加载
评论 #17358084 未加载
评论 #17358105 未加载
评论 #17357326 未加载
评论 #17359924 未加载
fabian2kalmost 7 years ago
Table inheritance has some serious limitations regarding foreign keys and some other aspects. The following warning is in the official documentation in that chapter:<p>&gt; These deficiencies will probably be fixed in some future release, but in the meantime considerable care is needed in deciding whether inheritance is useful for your application.
评论 #17357857 未加载
评论 #17357725 未加载
theandrewbaileyalmost 7 years ago
Seeing this has made me realize that I have one HUGE bug with native Postgres full text search.<p>On my blog, I have a lot of articles about the game series Borderlands. If you type &quot;Borderlands&quot; into the search box, it will find them, but if you type &quot;border lands&quot;, it won&#x27;t. Same with &quot;starcraft&quot; and &quot;star craft&quot;, etc.<p>It looks like I will have to implement trigrams on top of full text search to fix:<p><a href="https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;current&#x2F;static&#x2F;pgtrgm.html" rel="nofollow">https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;current&#x2F;static&#x2F;pgtrgm.html</a>
评论 #17362421 未加载
评论 #17361050 未加载
ddebernardyalmost 7 years ago
Table inheritance is a non-starter for the stated use-case. Just don&#x27;t. If memory serves me well even the Postgres docs recommended against using it for that last I read them. The only sane use-case of inheritance I&#x27;m aware of is when you&#x27;re partitioning a table.
评论 #17358558 未加载
评论 #17363143 未加载
评论 #17358026 未加载
brasetvikalmost 7 years ago
Another feature that should probably be on that list is Common Table Expressions: <a href="https:&#x2F;&#x2F;momjian.us&#x2F;main&#x2F;writings&#x2F;pgsql&#x2F;cte.pdf" rel="nofollow">https:&#x2F;&#x2F;momjian.us&#x2F;main&#x2F;writings&#x2F;pgsql&#x2F;cte.pdf</a><p>(I still frequently run into people who work a lot with SQL that don&#x27;t use CTEs, though less than before :)
评论 #17358276 未加载
评论 #17358260 未加载
评论 #17358330 未加载
megousalmost 7 years ago
Some others more or less obscure features I used and liked:<p>- data checksuming (can be enabled in initdb)<p>- extending the database in C (mostly adding various functions, that would be hard and slow to implement in SQL, but I&#x27;ve also been able to write functions that generate datasets on the fly that are loaded from a custom server over a unix socket)<p>- writing ECPG clients <a href="https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;current&#x2F;static&#x2F;ecpg.html" rel="nofollow">https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;current&#x2F;static&#x2F;ecpg.html</a>
booleanbetrayalalmost 7 years ago
FDW is awesome and surprisingly useful. I really want Postgres 10&#x27;s partitioning support to land in an AWS Redshift PG-reboot someday. Partitioning support is very manual and clunky in that old fork.
评论 #17357693 未加载
评论 #17357666 未加载
评论 #17358018 未加载
andreareinaalmost 7 years ago
Anybody who&#x27;s used the array types care to share their experience? It&#x27;s something that caught my eye reading the docs, but wasn&#x27;t sure how it holds up in actual use.
评论 #17357622 未加载
评论 #17357650 未加载
评论 #17357914 未加载
评论 #17357536 未加载
评论 #17359640 未加载
评论 #17358200 未加载
评论 #17357959 未加载
评论 #17357496 未加载
wwwestonalmost 7 years ago
Table inheritance seems like a natural one for devs working with a lot of class oriented languages. But also, composition over inheritance seems to be a more frequent watchword. Any experiences using this one?<p>Also, triggers seem pretty controversial in the discussions I&#x27;ve been privy too, most devs seem to hate them. Any positive experiences with them?
评论 #17358007 未加载
评论 #17358168 未加载
评论 #17357916 未加载
评论 #17357828 未加载
评论 #17357541 未加载
评论 #17357698 未加载
magicbuzzalmost 7 years ago
Interesting that there is inverted index support (ie GIN). Elasticsearch seems to make a big thing of using inverted indices.
评论 #17358365 未加载
o_____________oalmost 7 years ago
Site is down, mirror:<p><a href="https:&#x2F;&#x2F;webcache.googleusercontent.com&#x2F;search?q=cache:kQC5xWrxqF4J:https:&#x2F;&#x2F;pgdash.io&#x2F;blog&#x2F;postgres-features.html?h&amp;num=1&amp;hl=en&amp;gl=us&amp;strip=1&amp;vwsrc=0" rel="nofollow">https:&#x2F;&#x2F;webcache.googleusercontent.com&#x2F;search?q=cache:kQC5xW...</a>
luordalmost 7 years ago
I already knew a few of this, but still, damn, PostgreSQL is such an awesome piece of software.
joaodlfalmost 7 years ago
Pub&#x2F;Sub is a feature I had no idea about! Sounds really useful for most of my use cases.
davidwalmost 7 years ago
A lot of these things are neat. However, they are sharp tools with specific uses that you should be careful with and understand well before employing them.
matte_blackalmost 7 years ago
Also, Lateral Joins for queries you never thought possible.
bandramialmost 7 years ago
Are people really not using inheritance? I think of that as the main reason to choose postgres over a non-ORDBM
评论 #17357788 未加载
评论 #17357830 未加载
评论 #17357836 未加载