<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Psql on ads' corner</title><link>https://andreas.scherbaum.la/tags/psql/</link><description>Recent content in Psql on ads' corner</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Thu, 04 Dec 2025 00:00:00 +0200</lastBuildDate><atom:link href="https://andreas.scherbaum.la/tags/psql/index.xml" rel="self" type="application/rss+xml"/><item><title>The 1600 columns limit in PostgreSQL - how many columns fit into a table</title><link>https://andreas.scherbaum.la/post/2025-12-04_the-1600-columns-limit-in-postgresql-how-many-columns-fit-into-a-table/</link><pubDate>Thu, 04 Dec 2025 00:00:00 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2025-12-04_the-1600-columns-limit-in-postgresql-how-many-columns-fit-into-a-table/</guid><description>&lt;p&gt;A recent blog posting by &lt;a href="https://postgresql.life/post/frederic_delacourt/"&gt;Frédéric Delacourt&lt;/a&gt; (&lt;a href="https://www.data-bene.io/en/blog/did-you-know-tables-in-postgresql-are-limited-to-1600-columns/"&gt;Did you know? Tables in PostgreSQL are limited to 1,600 columns&lt;/a&gt;) reminded me once again that in the analytics world customers sometimes ask for more than 1600 columns.&lt;/p&gt;&#10;&lt;p&gt;Quick recap: in &lt;a href="https://en.wikipedia.org/wiki/Online_transaction_processing"&gt;OLTP&lt;/a&gt;, the aim is (usually) to use the &lt;a href="https://en.wikipedia.org/wiki/Third_normal_form"&gt;3rd normal form&lt;/a&gt;. In &lt;a href="https://en.wikipedia.org/wiki/Online_analytical_processing"&gt;OLAP&lt;/a&gt;, tables are often only vaguely normalized, and wide or very wide fact tables in &lt;a href="https://en.wikipedia.org/wiki/Second_normal_form"&gt;2nd normal form&lt;/a&gt; are quite common. But are 1600 columns a bad idea? Yes. Do some applications generate such wide tables? Also yes. I&amp;rsquo;ve seen my fair share of customer requests and support tickets asking if the 1600 columns limit can be raised or even lifted.&lt;/p&gt;</description></item><item><title>PGSqlPhriday #006: One Thing You Wish You Knew While Learning PostgreSQL: psql commands</title><link>https://andreas.scherbaum.la/post/2023-03-05_pgsqlphriday-006-one-thing-you-wish-you-knew-while-learning-postgresql-psql-commands/</link><pubDate>Sun, 05 Mar 2023 19:24:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2023-03-05_pgsqlphriday-006-one-thing-you-wish-you-knew-while-learning-postgresql-psql-commands/</guid><description>&lt;p&gt;For this month&amp;rsquo;s &lt;a href="https://www.pgsqlphriday.com/"&gt;#PGSQLPhriday&lt;/a&gt;, &lt;a href="https://www.scarydba.com/2023/02/24/one-thing-you-wish-you-knew-while-learning-postgresql-pgsqlphriday-006/"&gt;Grant Fritchey asks&lt;/a&gt;: What is the one thing you wish you knew while you learn &lt;em&gt;PostgreSQL&lt;/em&gt;.&lt;/p&gt;</description></item><item><title>PostgreSQL 95</title><link>https://andreas.scherbaum.la/post/2023-02-15_postgresql-95/</link><pubDate>Wed, 15 Feb 2023 21:36:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2023-02-15_postgresql-95/</guid><description>&lt;p&gt;Someone at &lt;a href="https://2023.fosdempgday.org/"&gt;FOSDEM 2023&lt;/a&gt; asked the question: &amp;ldquo;What happens when &lt;em&gt;PostgreSQL&lt;/em&gt; rolls over the version number to 95? Will this cause problems like back then in Windows?&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;What does that even mean? When Microsoft released the version after &lt;em&gt;Windows 98&lt;/em&gt;, they opted for naming it &lt;em&gt;Windows 10&lt;/em&gt;, not &lt;em&gt;Windows 9&lt;/em&gt;. Because apparently a lot of code out there checks if the string &lt;a href="https://www.pcworld.com/article/435584/why-windows-10-isnt-named-9-windows-95-legacy-code.html"&gt;starts with &amp;ldquo;Windows 9&amp;rdquo;&lt;/a&gt; and then assumes that the OS is one of the very old ones. This might not be the only such problem, as another blog article by Microsoft shows. Apparently &lt;a href="https://devblogs.microsoft.com/oldnewthing/20040213-00/?p=40633"&gt;they used &amp;ldquo;3.95&amp;rdquo; for the Windows 95 internal version&lt;/a&gt;, because lazy programmers.&lt;/p&gt;</description></item><item><title>PGSQL Phriday #001: Two truths and a lie</title><link>https://andreas.scherbaum.la/post/2022-10-07_pgsql-phriday-001-two-truths-and-a-lie/</link><pubDate>Fri, 07 Oct 2022 18:42:00 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2022-10-07_pgsql-phriday-001-two-truths-and-a-lie/</guid><description>&lt;p&gt;Uh, what is this &lt;a href="https://andreas.scherbaum.la/tags/pgsqlphriday"&gt;#PGSQLPhriday&lt;/a&gt; thing about? Everyone is writing blog posts about this today &amp;hellip; For details, please read the &lt;a href="https://www.softwareandbooz.com/pgsql-phriday-001-invite/"&gt;introduction from Ryan Booz&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;This month&amp;rsquo;s topic: pick your three favorite or most important best pratices for #PostgreSQL. Tell them in a form that two are true, one is a lie. See if you can spot which one is true and which one is false. The resolution is at the end of this blog posting.&lt;/p&gt;</description></item><item><title>Changes to the public schema in PostgreSQL 15 and how to handle upgrades</title><link>https://andreas.scherbaum.la/post/2022-08-30_changes-to-the-public-schema-in-postgresql-15-and-how-to-handle-upgrades/</link><pubDate>Tue, 30 Aug 2022 16:26:00 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2022-08-30_changes-to-the-public-schema-in-postgresql-15-and-how-to-handle-upgrades/</guid><description>&lt;p&gt;In September 2021, a patch for the upcoming &lt;em&gt;PostgreSQL&lt;/em&gt; version 15 was &lt;a href="https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=b073c3ccd06e4cb845e121387a43faa8c68a7b62"&gt;committed&lt;/a&gt; which introduces a visible change for users: the &lt;code&gt;CREATE&lt;/code&gt; privilege for the &lt;code&gt;public&lt;/code&gt; schema is no longer set by default. This is a recommendation from &lt;a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-1058"&gt;CVE-2018-1058&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;What does that mean for the average (non-superuser) user?&lt;/p&gt;</description></item><item><title>2 + 2 * 4 = 16?</title><link>https://andreas.scherbaum.la/post/2022-07-01_2-+-2-4-16/</link><pubDate>Fri, 01 Jul 2022 12:35:00 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2022-07-01_2-+-2-4-16/</guid><description>&lt;p&gt;&lt;a href="https://kubieziel.de/blog/"&gt;Jens Kubieziel&lt;/a&gt; recently posted a &lt;a href="https://twitter.com/qbi/status/1541315063428030464"&gt;Twitter poll&lt;/a&gt;: 2 + 2 * 4&lt;/p&gt;&#10;&lt;p&gt;The available options:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;16&lt;/li&gt;&#10;&lt;li&gt;15&lt;/li&gt;&#10;&lt;li&gt;14&lt;/li&gt;&#10;&lt;li&gt;13&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Notably absent is the &lt;a href="https://www.wolframalpha.com/input?i=2+%2B+2+*+4"&gt;correct result&lt;/a&gt; (at least for our ordinary mathematics). This poll is a &lt;a href="https://en.wikipedia.org/wiki/No-win_situation"&gt;No-Win Situation&lt;/a&gt;: you can&amp;rsquo;t win, because the correct result is not available as an option.&lt;/p&gt;&#10;&lt;p&gt;Nevertheless I had an idea, but for this I had to wait until the poll closes.&lt;/p&gt;</description></item><item><title>ctid and other PostgreSQL table internals</title><link>https://andreas.scherbaum.la/post/2022-06-28_ctid-and-other-postgresql-table-internals/</link><pubDate>Tue, 28 Jun 2022 16:36:00 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2022-06-28_ctid-and-other-postgresql-table-internals/</guid><description>&lt;p&gt;While attending a conference (yay) the discussion turned to system columns, and especially &lt;code&gt;ctid&lt;/code&gt;. This was in context of backups, and the physical position of data on disk. The question was if that can be used to determine if an incremental backup is required, and if it is enough to just copy that field where the &lt;code&gt;ctid&lt;/code&gt; points to. Not quite, but I’d like to use this question to describe the &lt;a href="https://www.postgresql.org/docs/current/ddl-system-columns.html"&gt;system columns&lt;/a&gt; more in detail.&lt;/p&gt;</description></item><item><title>My PostgreSQL database is empty!</title><link>https://andreas.scherbaum.la/post/2022-06-11_my-postgresql-database-is-empty/</link><pubDate>Sat, 11 Jun 2022 20:08:00 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2022-06-11_my-postgresql-database-is-empty/</guid><description>&lt;p&gt;The one thing I like to do is challenge &lt;a href="https://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; - and readers - to the extreme. A while ago I posted about the &lt;a href="https://andreas.scherbaum.la/post/2022-05-03_its-beer-oclock-for-postgresql/"&gt;Beer o&amp;rsquo;clock&lt;/a&gt;. Building &lt;a href="https://andreas.scherbaum.la/post/2022-01-27_not-so-equal-texts-in-postgresql-and-how-to-compare-texts-in-a-more-elaborate-way/"&gt;Zoé&lt;/a&gt; was another interesting example. And at some point I blog about Dancing with the Stars as well. Today it&amp;rsquo;s all about nothing. Empty. Where is all the data gone?&lt;/p&gt;&#10;&lt;p&gt;A while ago I posted &lt;a href="https://twitter.com/ascherbaum/status/1517832463829147648"&gt;this screenshot on Twitter&lt;/a&gt;, and as far as I can tell no one found the correct answer.&lt;/p&gt;</description></item><item><title>It's beer o'clock for PostgreSQL</title><link>https://andreas.scherbaum.la/post/2022-05-03_its-beer-oclock-for-postgresql/</link><pubDate>Tue, 03 May 2022 11:50:00 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2022-05-03_its-beer-oclock-for-postgresql/</guid><description>&lt;p&gt;A couple days ago &lt;a href="https://twitter.com/DevrimGunduz/status/1519708131433066500"&gt;Devrim forked PostgreSQL to get a beer&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;That effort is of course laudable, but a bit extreme.&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;PostgreSQL&lt;/em&gt; is very extensible, and allows to implement a beer now clock with just a few easy steps.&lt;/p&gt;</description></item><item><title>Not so equal texts in PostgreSQL - and how to compare texts in a more elaborate way</title><link>https://andreas.scherbaum.la/post/2022-01-27_not-so-equal-texts-in-postgresql-and-how-to-compare-texts-in-a-more-elaborate-way/</link><pubDate>Thu, 27 Jan 2022 00:39:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2022-01-27_not-so-equal-texts-in-postgresql-and-how-to-compare-texts-in-a-more-elaborate-way/</guid><description>&lt;p&gt;&lt;a href="https://thebuild.com/blog/"&gt;Christophe Pettus&lt;/a&gt; posted an &lt;a href="https://twitter.com/Xof/status/1485682904625659906"&gt;interesting challenge here&lt;/a&gt;. Two strings which on the surface look equal, but if you ask &lt;em&gt;PostgreSQL&lt;/em&gt; to compare them, they are not equal.&lt;/p&gt;&#10;&lt;p&gt;Now let me start with a note: &lt;em&gt;Twitter&lt;/em&gt; totally screws this challenge up.&lt;/p&gt;&#10;&lt;p&gt;How so? Although the two strings are different in the &lt;a href="https://twitter.com/Xof/status/1485769965902786560"&gt;original&lt;/a&gt;, when posting this to &lt;em&gt;Twitter&lt;/em&gt; the strings are made equal. Where is the fun in that?&lt;/p&gt;</description></item><item><title>Advent of Code 2020: "Seating System" - Day 11</title><link>https://andreas.scherbaum.la/post/2020-12-12_advent-of-code-2020-seating-system-day-11/</link><pubDate>Sat, 12 Dec 2020 22:42:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2020-12-12_advent-of-code-2020-seating-system-day-11/</guid><description>&lt;p&gt;Your career as a hacker brings you &lt;a href="https://adventofcode.com/2020/day/11"&gt;more and more unreasonable tasks&lt;/a&gt;. Today you arrive at the ferry station, head to your next gate (no one mentioned if you &lt;a href="https://andreas.scherbaum.la/post/2020-12-10_advent-of-code-2020-adapter-array-day-10/"&gt;even got an ice cream&lt;/a&gt;), and figure out where to seat. Even though you are the first person in the waiting area that does not stop you from knowing the seating habits for all other passengers, and calculate their seating patterns.&lt;/p&gt;</description></item><item><title>Advent of Code 2020: "Adapter Array" - Day 10</title><link>https://andreas.scherbaum.la/post/2020-12-10_advent-of-code-2020-adapter-array-day-10/</link><pubDate>Thu, 10 Dec 2020 22:21:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2020-12-10_advent-of-code-2020-adapter-array-day-10/</guid><description>&lt;p&gt;After you finished &lt;a href="https://andreas.scherbaum.la/post/2020-12-09_advent-of-code-2020-encoding-error-day-9/"&gt;hacking the plane&lt;/a&gt;, your laptop dies: you forgot to charge it! Rookie mistake, or the calculations do consume a lot of power. The plane has a power outlet, but somehow it&amp;rsquo;s a non-standard one, you need an adapter. But first a cocktail! Then you empty your backback on the seat next to you and &lt;a href="https://adventofcode.com/2020/day/10"&gt;find out that you have dozens of different adapters&lt;/a&gt;, which you can &lt;a href="https://superuser.com/questions/1122204/how-many-port-adapters-and-which-ones-can-be-stacked-up-and-actually-work"&gt;stack together&lt;/a&gt;. None of them really work, and hopefully you don&amp;rsquo;t blow another fuse, or set the &lt;a href="https://www.youtube.com/watch?v=uiqvXKyhkiw"&gt;plane on fire&lt;/a&gt;!&lt;/p&gt;</description></item><item><title>Advent of Code 2020: "Encoding Error" - Day 9</title><link>https://andreas.scherbaum.la/post/2020-12-09_advent-of-code-2020-encoding-error-day-9/</link><pubDate>Wed, 09 Dec 2020 21:43:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2020-12-09_advent-of-code-2020-encoding-error-day-9/</guid><description>&lt;p&gt;Uh oh, either the ice cream at the airport was bad, or the &lt;a href="https://andreas.scherbaum.la/post/2020-12-08_advent-of-code-2020-handheld-halting-day-8/"&gt;cocktails&lt;/a&gt; are not good for you! How else can you explain that you hack the airplane systems with some &lt;a href="https://en.wikipedia.org/wiki/Clippy"&gt;paperclips&lt;/a&gt; and break the &lt;a href="https://en.wikipedia.org/wiki/Xmas"&gt;XMAS&lt;/a&gt; &lt;a href="https://en.wikipedia.org/wiki/Encryption"&gt;encryption&lt;/a&gt;, while the plane is &lt;a href="https://en.wikipedia.org/wiki/Takeoff"&gt;airborne&lt;/a&gt;? The plane&amp;rsquo;s on-board systems emits some cryptic numbers and &lt;a href="https://adventofcode.com/2020/day/9"&gt;your task&lt;/a&gt; is it to decrypt this. Wait, did I say task? &lt;a href="https://en.wikipedia.org/wiki/Mission:_Impossible"&gt;Who gave this task to you&lt;/a&gt;? Oh well, please be careful, if you shorten a circuit you might as well crash your own plane.&lt;/p&gt;</description></item><item><title>Advent of Code 2020: "Handheld Halting" - Day 8</title><link>https://andreas.scherbaum.la/post/2020-12-08_advent-of-code-2020-handheld-halting-day-8/</link><pubDate>Tue, 08 Dec 2020 23:56:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2020-12-08_advent-of-code-2020-handheld-halting-day-8/</guid><description>&lt;p&gt;You fixed the &lt;a href="https://andreas.scherbaum.la/post/2020-12-07_advent-of-code-2020-handy-haversacks-day-7/"&gt;colours of the bags yesterday&lt;/a&gt; and security allowed you to leave the baggage section and go get your ice cream before you board your next flight. On the flight the kid next to you recognizes you as the great hacker you are, and &lt;a href="https://adventofcode.com/2020/day/8"&gt;asks you to fix a problem&lt;/a&gt; with the handheld game console. Go and hack the bootloader while no documentation is available because the mobile internet is off. Turns out someone coded an infinite loop into the bootloader, and missed that fact during testing. What testing, do you ask? Well, let&amp;rsquo;s not jump too deep into details, you have to hack a bootloader and make a kid happy. It&amp;rsquo;s Christmas soon, after all! And your cocktail is waiting!&lt;/p&gt;</description></item><item><title>Advent of Code 2020: "Handy Haversacks" - Day 7</title><link>https://andreas.scherbaum.la/post/2020-12-07_advent-of-code-2020-handy-haversacks-day-7/</link><pubDate>Mon, 07 Dec 2020 21:08:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2020-12-07_advent-of-code-2020-handy-haversacks-day-7/</guid><description>&lt;p&gt;They really trust you a lot &amp;hellip; Now all flights are delayed, that&amp;rsquo;s quite usual in advent times. Except it&amp;rsquo;s &lt;code&gt;2020&lt;/code&gt; and no one is traveling anyway. But they also impose more regulations, and now bags need to have colours, and bags need to go into other bags. And &lt;a href="https://adventofcode.com/2020/day/7"&gt;someone has to figure it out&lt;/a&gt;. That&amp;rsquo;s right, it&amp;rsquo;s you! I hope the stopover is long enough to at least grab some ice cream!&lt;/p&gt;</description></item><item><title>Advent of Code 2020: "Custom Customs" - Day 6</title><link>https://andreas.scherbaum.la/post/2020-12-06_advent-of-code-2020-custom-customs-day-6/</link><pubDate>Sun, 06 Dec 2020 22:35:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2020-12-06_advent-of-code-2020-custom-customs-day-6/</guid><description>&lt;p&gt;The flight is approaching a regional airport, but you still have to fill out a &lt;a href="https://adventofcode.com/2020/day/6"&gt;customs form&lt;/a&gt;. Since you are good with hacking things together, you walk around the plane and gather all the answers from all groups on the plane. There are &lt;code&gt;26&lt;/code&gt; yes-or-no questions, marked from &lt;code&gt;a&lt;/code&gt; to &lt;code&gt;z&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Advent of Code 2020: "Binary Boarding" - Day 5</title><link>https://andreas.scherbaum.la/post/2020-12-05_advent-of-code-2020-binary-boarding-day-5/</link><pubDate>Sat, 05 Dec 2020 18:24:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2020-12-05_advent-of-code-2020-binary-boarding-day-5/</guid><description>&lt;p&gt;Pretty amazing the tasks they ask you to do &amp;ldquo;on the fly&amp;rdquo;: &lt;a href="https://andreas.scherbaum.la/post/2020-12-05_advent-of-code-2020-passport-processing-day-4/"&gt;Yesterday&lt;/a&gt; we fixed the passport scanner, &lt;a href="https://adventofcode.com/2020/day/5"&gt;today&lt;/a&gt; you have to write a piece of code which scans all the boarding passes in your environment (no one said they all carry them in the hand, and show it to you), and while waiting in the gangway you also have to identify your designated seat. Because, you know, you are such a good hacker you lost your &lt;a href="https://en.wikipedia.org/wiki/Boarding_pass"&gt;boarding pass&lt;/a&gt; on the &lt;a href="https://en.wikipedia.org/wiki/Jet_bridge"&gt;way&lt;/a&gt; from the gate to the plane ;-)&lt;/p&gt;</description></item><item><title>Advent of Code 2020: "Passport Processing" - Day 4</title><link>https://andreas.scherbaum.la/post/2020-12-05_advent-of-code-2020-passport-processing-day-4/</link><pubDate>Sat, 05 Dec 2020 16:50:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2020-12-05_advent-of-code-2020-passport-processing-day-4/</guid><description>&lt;p&gt;The challenge for day 4 is more suited for databases. The input is fuzzy, but with a &lt;a href="https://www.postgresql.org/docs/current/queries-with.html"&gt;CTE&lt;/a&gt; or two I should be able to clean it up. Solved the first part already with the &lt;a href="https://twitter.com/pscherbaum/status/1335238751363194880"&gt;kid&lt;/a&gt; earlier, but we decided to skip part two: mainly because it involved more complex string operations (best suited for regex operations), which is something the kid hasn&amp;rsquo;t learned yet.&lt;/p&gt;</description></item><item><title>Advent of Code 2020: "Toboggan Trajectory" - Day 3</title><link>https://andreas.scherbaum.la/post/2020-12-03_advent-of-code-2020-toboggan-trajectory-day-3/</link><pubDate>Thu, 03 Dec 2020 22:52:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2020-12-03_advent-of-code-2020-toboggan-trajectory-day-3/</guid><description>&lt;p&gt;Have to admit, on first glance &lt;a href="https://adventofcode.com/2020/day/3"&gt;this challenge&lt;/a&gt; looks a bit complicated. It&amp;rsquo;s well suited for languages which can do string manipulations, but it&amp;rsquo;s not well suited for &lt;a href="https://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt;. Earlier today I already looked at this problem together with &lt;a href="https://twitter.com/pscherbaum/status/1334550125797105664"&gt;the kid&lt;/a&gt;, in &lt;em&gt;Python&lt;/em&gt;. Therefore I already knew that I have to jump multiple rows as well. To sum it up: &lt;em&gt;adjust x, including overruns, jump multiple rows in y direction, count trees along the way&lt;/em&gt;. All in a single SQL query.&lt;/p&gt;&#10;&lt;p&gt;Decided to do the map search in a &lt;a href="https://www.postgresql.org/docs/current/plpgsql.html"&gt;pl/pgSQL&lt;/a&gt; instead, and write a function for it.&lt;/p&gt;</description></item><item><title>Advent of Code 2020: "Password Philosophy" - Day 2</title><link>https://andreas.scherbaum.la/post/2020-12-02_advent-of-code-2020-password-philosophy-day-2/</link><pubDate>Wed, 02 Dec 2020 22:57:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2020-12-02_advent-of-code-2020-password-philosophy-day-2/</guid><description>&lt;p&gt;&lt;a href="https://adventofcode.com/2020/day/2"&gt;Day 2&lt;/a&gt;, another challenge: fix a broken password database. In order to do that, the passwords which violate the policy must be identified.&lt;/p&gt;</description></item><item><title>Advent of Code 2020: "Report Repair" - Day 1</title><link>https://andreas.scherbaum.la/post/2020-12-01_advent-of-code-2020-report-repair-day-1/</link><pubDate>Tue, 01 Dec 2020 18:51:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2020-12-01_advent-of-code-2020-report-repair-day-1/</guid><description>&lt;p&gt;Started &amp;ldquo;&lt;a href="https://adventofcode.com/2020/"&gt;Advent of Code&lt;/a&gt;&amp;rdquo; with the &lt;a href="https://pascal.scherbaum.la/blog/"&gt;kid&lt;/a&gt;, the kid is polishing the &lt;em&gt;Python&lt;/em&gt; (and &lt;em&gt;English&lt;/em&gt;) skills. I thought I better do this in &lt;a href="https://www.postgresql.org/"&gt;SQL&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>SELECT pg_sleep_until('#800Monies');</title><link>https://andreas.scherbaum.la/post/2020-01-17_select-pg_sleep_until800monies/</link><pubDate>Fri, 17 Jan 2020 00:34:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2020-01-17_select-pg_sleep_until800monies/</guid><description>&lt;p&gt;Pavlo recently &lt;a href="https://twitter.com/PavloGolub/status/1217391570267377664"&gt;pointed out&lt;/a&gt; that the &lt;a href="https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-DELAY"&gt;pg_sleep() function&lt;/a&gt; in &lt;a href="https://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; has two alternatives: &lt;code&gt;pg_sleep_for()&lt;/code&gt; and &lt;code&gt;pg_sleep_until()&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;What do they do?&lt;/p&gt;</description></item><item><title>How long will a 64 bit Transaction-ID last in PostgreSQL?</title><link>https://andreas.scherbaum.la/post/2019-02-03_how-long-will-a-64-bit-transaction-id-last-in-postgresql/</link><pubDate>Sun, 03 Feb 2019 14:34:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2019-02-03_how-long-will-a-64-bit-transaction-id-last-in-postgresql/</guid><description>&lt;p&gt;At &lt;a href="https://fosdem.org/2019/"&gt;FOSDEM&lt;/a&gt; someone asked how long 64 bit Transaction-IDs will last.&lt;/p&gt;&#10;&lt;p&gt;To refresh: &lt;a href="https://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; is currently using &lt;a href="https://en.wikipedia.org/wiki/32-bit"&gt;32 bits&lt;/a&gt; for the TXID, and is good for around 4 billion transactions:&lt;/p&gt;</description></item><item><title>PostgreSQL with natural language support</title><link>https://andreas.scherbaum.la/post/2011-04-01_postgresql-with-natural-language-support/</link><pubDate>Fri, 01 Apr 2011 00:00:00 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2011-04-01_postgresql-with-natural-language-support/</guid><description>&lt;p&gt;In today&amp;rsquo;s fast development cycles and with the available, rapidly changing technologies there is less time for the rational planning of a new application. Since the database is usually the last in the development chain, programmers tend to avoid learning yet another programming language for relational databases. The &lt;a href="https://www.postgresql.org/"&gt;PostgreSQL Project&lt;/a&gt; is aware of this problem.&lt;/p&gt;</description></item><item><title>PostgreSQL 9.0: Includes the new MySQL Emulation Layer</title><link>https://andreas.scherbaum.la/post/2010-04-01_postgresql-9.0-includes-the-new-mysql-emulation-layer/</link><pubDate>Thu, 01 Apr 2010 00:01:00 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2010-04-01_postgresql-9.0-includes-the-new-mysql-emulation-layer/</guid><description>&lt;p&gt;&lt;em&gt;PostgreSQL&lt;/em&gt; 9.0.0, released today, contains the &lt;em&gt;MySQL Emulation Layer&lt;/em&gt;.&lt;/p&gt;&#10;&lt;p&gt;To enable this feature, set the &lt;code&gt;mysql_compatible&lt;/code&gt; option GUC to &lt;code&gt;on&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>PostgreSQL 8.4: Column Permissions</title><link>https://andreas.scherbaum.la/post/2009-07-01_postgresql-8.4-column-permissions/</link><pubDate>Wed, 01 Jul 2009 19:00:00 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2009-07-01_postgresql-8.4-column-permissions/</guid><description>&lt;p&gt;Up to &lt;a href="https://www.postgresql.org/"&gt;&lt;em&gt;PostgreSQL&lt;/em&gt;&lt;/a&gt; 8.3 it was only possible to &lt;a href="https://www.postgresql.org/docs/8.3/static/sql-grant.html"&gt;grant&lt;/a&gt; (and &lt;a href="https://www.postgresql.org/docs/8.3/static/sql-revoke.html"&gt;revoke&lt;/a&gt;) permissions on the entire table. If column level permissions were needed, a workaround like a &lt;a href="https://www.postgresql.org/docs/8.4/static/sql-createview.html"&gt;view&lt;/a&gt; solved (more or less) the problem: create the view with the required (allowed) columns, revoke all permissions from the underlaying table, grant permissions to the view.&lt;/p&gt;</description></item><item><title>Speed up your Serendipity blog running on PostgreSQL</title><link>https://andreas.scherbaum.la/post/2008-11-29_speed-up-your-serendipity-blog-running-on-postgresql/</link><pubDate>Sat, 29 Nov 2008 21:57:40 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2008-11-29_speed-up-your-serendipity-blog-running-on-postgresql/</guid><description>&lt;p&gt;In the last days I monitored the &lt;em&gt;PostgreSQL&lt;/em&gt; logfile on my webserver to find slow queries in the &lt;a href="https://www.s9y.org/"&gt;Serendipity blog software&lt;/a&gt;. I was &lt;a href="https://board.s9y.org/viewtopic.php?t=14263"&gt;hunting another bug&lt;/a&gt; in the &amp;ldquo;events&amp;rdquo; module, therefore I decided it&amp;rsquo;s woth the additional work and maybe I can tweak some settings to speed up the response time a bit.&lt;/p&gt;</description></item><item><title>Single line input for psql copy command</title><link>https://andreas.scherbaum.la/post/2008-10-08_single-line-input-for-psql-copy-command/</link><pubDate>Wed, 08 Oct 2008 22:26:05 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2008-10-08_single-line-input-for-psql-copy-command/</guid><description>&lt;p&gt;I have the following problem:&lt;/p&gt;&#10;&lt;p&gt;A database server and another client machine. I have to execute several &lt;code&gt;\copy&lt;/code&gt; commands in &lt;code&gt;psql&lt;/code&gt; on the client machine to retrieve data and store the output in CSV files. The &lt;em&gt;PostgreSQL&lt;/em&gt; &lt;code&gt;COPY&lt;/code&gt; command is not an option because it stores the results on the database server, not the client machine. All &lt;code&gt;\copy&lt;/code&gt; commands are executed from several files containing &lt;em&gt;SQL&lt;/em&gt; commands, which are concated together by a &lt;code&gt;Makefile&lt;/code&gt; and feeded into &lt;code&gt;psql&lt;/code&gt;. So far so good.&lt;/p&gt;</description></item><item><title>role ... cannot be dropped because some objects depend on it</title><link>https://andreas.scherbaum.la/post/2008-09-10_role-...-cannot-be-dropped-because-some-objects-depend-on-it/</link><pubDate>Wed, 10 Sep 2008 20:11:07 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2008-09-10_role-...-cannot-be-dropped-because-some-objects-depend-on-it/</guid><description>&lt;p&gt;I want to &lt;a href="https://www.postgresql.org/docs/8.3/interactive/sql-droprole.html"&gt;drop a ROLE&lt;/a&gt; (previously &lt;code&gt;USER&lt;/code&gt;/&lt;code&gt;GROUP&lt;/code&gt;s) which is still referenced by object(s) in my database. But &lt;a href="https://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; has objections:&lt;/p&gt;</description></item><item><title>create language if not exist</title><link>https://andreas.scherbaum.la/post/2008-03-27_create-language-if-not-exist/</link><pubDate>Thu, 27 Mar 2008 08:33:14 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2008-03-27_create-language-if-not-exist/</guid><description>&lt;p&gt;In a customer project I have to setup a database from a &lt;code&gt;Makefile&lt;/code&gt;. Part of my problem: on &lt;em&gt;Windows&lt;/em&gt; the installer may or may not install &lt;code&gt;plpgsql&lt;/code&gt; into &lt;code&gt;template1&lt;/code&gt;, therefore in consequence this language may or may not be activated in every new database. But that&amp;rsquo;s not predictable. This problem can appear on different &lt;em&gt;Linux&lt;/em&gt;/Unix distributions too.&lt;/p&gt;</description></item><item><title>BOOLEAN datatype with PHP-compatible output</title><link>https://andreas.scherbaum.la/post/2008-01-07_boolean-datatype-with-php-compatible-output/</link><pubDate>Mon, 07 Jan 2008 12:43:31 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2008-01-07_boolean-datatype-with-php-compatible-output/</guid><description>&lt;p&gt;If you use pure &lt;em&gt;PHP&lt;/em&gt; (no database abstraction layer) with &lt;em&gt;PostgreSQL&lt;/em&gt;, you may run into the problem that your &lt;code&gt;BOOLEAN&lt;/code&gt; columns are not recognized by &lt;em&gt;PHP&lt;/em&gt; but the value is instead returned as a string.&lt;/p&gt;</description></item><item><title>table size, database size</title><link>https://andreas.scherbaum.la/post/2007-12-04_table-size-database-size/</link><pubDate>Tue, 04 Dec 2007 11:07:00 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2007-12-04_table-size-database-size/</guid><description>&lt;p&gt;I have seen this question &lt;a href="https://web.archive.org/web/20101210103329/https://www.postgresqlforums.com/forums/viewtopic.php?f=42&amp;amp;t=417"&gt;more than once&lt;/a&gt; in the past: &amp;ldquo;How much storage space do I need for my table?&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;PostgreSQL&lt;/em&gt; can give you &lt;a href="https://www.postgresql.org/docs/current/static/functions-admin.html#FUNCTIONS-ADMIN-DBSIZE"&gt;this information&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>stop psql on first error</title><link>https://andreas.scherbaum.la/post/2007-10-20_stop-psql-on-first-error/</link><pubDate>Sat, 20 Oct 2007 00:27:16 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2007-10-20_stop-psql-on-first-error/</guid><description>&lt;p&gt;Because I always forget how to stop &lt;code&gt;psql&lt;/code&gt; on the first error:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div style="background-color:#f7f7f7;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&#10;&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;&#10;&lt;pre tabindex="0" style="background-color:#f7f7f7;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;&#10;&lt;pre tabindex="0" style="background-color:#f7f7f7;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-postgresql" data-lang="postgresql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f6f8fa;background-color:#82071e"&gt;\&lt;/span&gt;&lt;span style="color:#cf222e"&gt;set&lt;/span&gt; ON_ERROR_STOP&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;You can include this at the top of your script/file, &lt;code&gt;psql&lt;/code&gt; will stop right after the first error and will not try to continue any other commands in the chain.&lt;/p&gt;</description></item><item><title>Avoid autovacuum for entire databases</title><link>https://andreas.scherbaum.la/post/2007-07-02_avoid-autovacuum-for-entire-databases/</link><pubDate>Mon, 02 Jul 2007 00:58:25 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2007-07-02_avoid-autovacuum-for-entire-databases/</guid><description>&lt;p&gt;We have a database with production data for a platform and another database with a production database dump for testing queries. We also have a test database but this one has slightly different DDL, because it&amp;rsquo;s for developing new features. Now &lt;em&gt;Autovacuum&lt;/em&gt; is running on this server and keeps vacuuming this test database.&lt;/p&gt;</description></item><item><title>Ringbuffer in SQL</title><link>https://andreas.scherbaum.la/post/2007-02-04_ringbuffer-in-sql/</link><pubDate>Sun, 04 Feb 2007 21:50:30 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2007-02-04_ringbuffer-in-sql/</guid><description>&lt;p&gt;On a student platform we show, on every page, a random user in the upper right corner. Because we have over 11.000 users, the database has to select all matching users and sort them by &lt;code&gt;random()&lt;/code&gt;. Thats very expensive and one of the longest running queries in the current version. And because we are currently redeveloping the whole platform, I decided to try something different for the random user. The user must not be really random, it should be enough to just display a different user every time the page is displayed. My idea was to implement a ringbuffer in SQL and forward the pointer to the next user in the buffer if we need to search the next random user.&lt;/p&gt;</description></item><item><title>Log Table Changes in PostgreSQL with tablelog</title><link>https://andreas.scherbaum.la/post/2007-02-01_log-table-changes-in-postgresql-with-tablelog/</link><pubDate>Thu, 01 Feb 2007 02:49:37 +0100</pubDate><guid>https://andreas.scherbaum.la/post/2007-02-01_log-table-changes-in-postgresql-with-tablelog/</guid><description>&lt;p&gt;Ever had the need to know what happened with your data? &lt;em&gt;Tablelog&lt;/em&gt; could be your answer.&lt;/p&gt;</description></item><item><title>Avoid Unique Key violation</title><link>https://andreas.scherbaum.la/post/2006-07-28_avoid-unique-key-violation/</link><pubDate>Fri, 28 Jul 2006 11:18:51 +0200</pubDate><guid>https://andreas.scherbaum.la/post/2006-07-28_avoid-unique-key-violation/</guid><description>&lt;p&gt;If you have a table with an unique key field, want to insert new values but you don&amp;rsquo;t know if the value may already be in the table, you can use the following query:&lt;/p&gt;</description></item></channel></rss>