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.

Show HN: PL/Swift – PostgreSQL Functions in Swift

84 pointsby helge5over 7 years ago

4 comments

alexnewmanover 7 years ago
A different approach I wrote in rust<p><a href="https:&#x2F;&#x2F;github.com&#x2F;posix4e&#x2F;rpgffi" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;posix4e&#x2F;rpgffi</a><p>With some example consumers: <a href="https:&#x2F;&#x2F;github.com&#x2F;durch&#x2F;google-bigtable-postgres-fdw" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;durch&#x2F;google-bigtable-postgres-fdw</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;posix4e&#x2F;jsoncdc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;posix4e&#x2F;jsoncdc</a>
solidsnack9000over 7 years ago
Being able to push some application logic into the database server can be very powerful for batch operations. Often you need to make real decisions in application logic at several steps along the way.<p>If you use an ORM-like coding style, you get orderly code but performance is terrible because (a) every row is handled in its own transaction and (b) even if it wasn’t there are multiple network round trips per row. One is thus compelled to write a kind of hybrid: insert a thousand rows, do some join, for each row that is returned, add a row to the pile of stuff to be inserted next, do that insert, and so on and so forth, for many steps. Instead of having a loop like:<p><pre><code> for data in input { step1(); step2(); ... } </code></pre> ...you get code that reads like: do step1 for a thousand items, insert, do step2() for a thouand items, insert...<p>With the code running directly in the database, you can write it in a more naive, ORM like style, because calling into the database for an INSERT or SELECT is much cheaper than a network round trip.
评论 #16094896 未加载
cyberonover 7 years ago
Looks interesting PoC. I have written multiple extensions for PostgreSQL in Go. The hardest part is not &quot;glueing&quot; together the tools to make it work. Most of the time it&#x27;s much more easier and faster to just write in C (C++ with wrapper).<p>There are many cases you should consider, like returning rows (composite types) and implementing trigger functions.
评论 #16092827 未加载
stevefan1999over 7 years ago
I’d suggest the authors to change the name, I thought it was about PL&#x2F;I at the first sight.
评论 #16093886 未加载