{"id":6529,"date":"2022-03-08T09:30:35","date_gmt":"2022-03-08T08:30:35","guid":{"rendered":"https:\/\/www.credativ.de\/?p=6529"},"modified":"2026-04-27T20:21:41","modified_gmt":"2026-04-27T18:21:41","slug":"sqlreduce-reduce-verbose-sql-queries-to-minimal-examples","status":"publish","type":"post","link":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/","title":{"rendered":"SQLreduce: Reduce verbose SQL queries to minimal examples"},"content":{"rendered":"<h1>SQLreduce: Reduce verbose SQL queries to minimal examples<\/h1>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6526\" src=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2022\/03\/sqlreduce.png\" alt=\"\" width=\"128\" height=\"122\" \/><\/p>\n<p>Developers often face very large SQL queries that raise some errors. SQLreduce is a tool to reduce that complexity to a minimal query.<\/p>\n<h2>SQLsmith generates random SQL queries<\/h2>\n<p><a href=\"https:\/\/github.com\/anse1\/sqlsmith\">SQLsmith<\/a> is a tool that generates random SQL queries and runs them against a PostgreSQL server (and other DBMS types). The idea is that by fuzz-testing the query parser and executor, corner-case bugs can be found that would otherwise go unnoticed in manual testing or with the fixed set of test cases in PostgreSQL&#8217;s regression test suite. It has proven to be an <a href=\"https:\/\/github.com\/anse1\/sqlsmith\/wiki#score-list\">effective tool<\/a> with over 100 bugs found in different areas in the PostgreSQL server and other products since 2015, including security bugs, ranging from executor bugs to segfaults in type and index method implementations. For example, in 2018, SQLsmith found that the following query <a href=\"https:\/\/www.postgresql.org\/message-id\/flat\/87woxi24uw.fsf%40ansel.ydns.eu\">triggered a segfault in PostgreSQL<\/a>:<\/p>\n<pre><code>select\r\n  case when pg_catalog.lastval() &lt; pg_catalog.pg_stat_get_bgwriter_maxwritten_clean() then case when pg_catalog.circle_sub_pt(\r\n          cast(cast(null as circle) as circle),\r\n          cast((select location from public.emp limit 1 offset 13)\r\n             as point)) ~ cast(nullif(case when cast(null as box) &amp;&gt; (select boxcol from public.brintest limit 1 offset 2)\r\n                 then (select f1 from public.circle_tbl limit 1 offset 4)\r\n               else (select f1 from public.circle_tbl limit 1 offset 4)\r\n               end,\r\n          case when (select pg_catalog.max(class) from public.f_star)\r\n                 ~~ ref_0.c then cast(null as circle) else cast(null as circle) end\r\n            ) as circle) then ref_0.a else ref_0.a end\r\n       else case when pg_catalog.circle_sub_pt(\r\n          cast(cast(null as circle) as circle),\r\n          cast((select location from public.emp limit 1 offset 13)\r\n             as point)) ~ cast(nullif(case when cast(null as box) &amp;&gt; (select boxcol from public.brintest limit 1 offset 2)\r\n                 then (select f1 from public.circle_tbl limit 1 offset 4)\r\n               else (select f1 from public.circle_tbl limit 1 offset 4)\r\n               end,\r\n          case when (select pg_catalog.max(class) from public.f_star)\r\n                 ~~ ref_0.c then cast(null as circle) else cast(null as circle) end\r\n            ) as circle) then ref_0.a else ref_0.a end\r\n       end as c0,\r\n  case when (select intervalcol from public.brintest limit 1 offset 1)\r\n         &gt;= cast(null as \"interval\") then case when ((select pg_catalog.max(roomno) from public.room)\r\n             !~~ ref_0.c)\r\n        and (cast(null as xid) &lt;&gt; 100) then ref_0.b else ref_0.b end\r\n       else case when ((select pg_catalog.max(roomno) from public.room)\r\n             !~~ ref_0.c)\r\n        and (cast(null as xid) &lt;&gt; 100) then ref_0.b else ref_0.b end\r\n       end as c1,\r\n  ref_0.a as c2,\r\n  (select a from public.idxpart1 limit 1 offset 5) as c3,\r\n  ref_0.b as c4,\r\n    pg_catalog.stddev(\r\n      cast((select pg_catalog.sum(float4col) from public.brintest)\r\n         as float4)) over (partition by ref_0.a,ref_0.b,ref_0.c order by ref_0.b) as c5,\r\n  cast(nullif(ref_0.b, ref_0.a) as int4) as c6, ref_0.b as c7, ref_0.c as c8\r\nfrom\r\n  public.mlparted3 as ref_0\r\nwhere true;\r\n<\/code><\/pre>\n<p>However, just like in this 40-line, 2.2kB example, the random queries generated by SQLsmith that trigger some error are most often very large and contain a lot of noise that does not contribute to the error. So far, manual inspection of the query and tedious editing was required to reduce the example to a minimal reproducer that developers can use to fix the problem.<\/p>\n<h2>Reduce complexity with SQLreduce<\/h2>\n<p>This issue is solved by <a href=\"https:\/\/github.com\/credativ\/sqlreduce\">SQLreduce<\/a>. SQLreduce takes as input an arbitrary SQL query which is then run against a PostgreSQL server. Various simplification steps are applied, checking after each step that the simplified query still triggers the same error from PostgreSQL. The end result is a SQL query with minimal complexity.<\/p>\n<p>SQLreduce is effective at reducing the queries from <a href=\"https:\/\/github.com\/anse1\/sqlsmith\/wiki#score-list\">original error reports from SQLsmith<\/a> to queries that match manually-reduced queries. For example, SQLreduce can effectively reduce the above monster query to just this:<\/p>\n<pre><code>SELECT pg_catalog.stddev(NULL) OVER () AS c5 FROM public.mlparted3 AS ref_0\r\n<\/code><\/pre>\n<p>Note that SQLreduce does not try to derive a query that is semantically identical to the original, or produces the same query result &#8211; the input is assumed to be faulty, and we are looking for the minimal query that produces the same error message from PostgreSQL when run against a database. If the input query happens to produce no error, the minimal query output by SQLreduce will just be <code>SELECT<\/code>.<\/p>\n<h2>How it works<\/h2>\n<p>We&#8217;ll use a simpler query to demonstrate how SQLreduce works and which steps are taken to remove noise from the input. The query is bogus and contains a bit of clutter that we want to remove:<\/p>\n<pre><code>$ psql -c 'select pg_database.reltuples \/ 1000 from pg_database, pg_class where 0 &lt; pg_database.reltuples \/ 1000 order by 1 desc limit 10'\r\nERROR:  column pg_database.reltuples does not exist\r\n<\/code><\/pre>\n<p>Let&#8217;s pass the query to SQLreduce:<\/p>\n<pre><code>$ sqlreduce 'select pg_database.reltuples \/ 1000 from pg_database, pg_class where 0 &lt; pg_database.reltuples \/ 1000 order by 1 desc limit 10'\r\n<\/code><\/pre>\n<p>SQLreduce starts by parsing the input using <a href=\"https:\/\/github.com\/lelit\/pglast\">pglast<\/a> and <a href=\"https:\/\/github.com\/pganalyze\/libpg_query\">libpg_query<\/a> which expose the original PostgreSQL parser as a library with Python bindings. The result is a parse tree that is the basis for the next steps. The parse tree looks like this:<\/p>\n<pre><code>selectStmt\r\n\u251c\u2500\u2500 targetList\r\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 \/\r\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 pg_database.reltuples\r\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 1000\r\n\u251c\u2500\u2500 fromClause\r\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 pg_database\r\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 pg_class\r\n\u251c\u2500\u2500 whereClause\r\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 &lt;\r\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 0\r\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 \/\r\n\u2502\u00a0\u00a0         \u251c\u2500\u2500 pg_database.reltuples\r\n\u2502\u00a0\u00a0         \u2514\u2500\u2500 1000\r\n\u251c\u2500\u2500 orderClause\r\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 1\r\n\u2514\u2500\u2500 limitCount\r\n    \u2514\u2500\u2500 10\r\n<\/code><\/pre>\n<p>Pglast also contains a query renderer that can render back the parse tree as SQL, shown as the regenerated query below. The input query is run against PostgreSQL to determine the result, in this case <code>ERROR:  column pg_database.reltuples does not exist<\/code>.<\/p>\n<pre><code>Input query: select pg_database.reltuples \/ 1000 from pg_database, pg_class where 0 &lt; pg_database.reltuples \/ 1000 order by 1 desc limit 10\r\nRegenerated: SELECT pg_database.reltuples \/ 1000 FROM pg_database, pg_class WHERE 0 &lt; ((pg_database.reltuples \/ 1000)) ORDER BY 1 DESC LIMIT 10\r\nQuery returns: \u2714 ERROR:  column pg_database.reltuples does not exist\r\n<\/code><\/pre>\n<p>SQLreduce works by deriving new parse trees that are structurally simpler, generating SQL from that, and run these queries against the database. The first simplification steps work on the top level node, where SQLreduce tries to remove whole subtrees to quickly find a result. The first reduction tried is to remove <code>LIMIT 10<\/code>:<\/p>\n<pre><code>SELECT pg_database.reltuples \/ 1000 FROM pg_database, pg_class WHERE 0 &lt; ((pg_database.reltuples \/ 1000)) ORDER BY 1 DESC \u2714\r\n<\/code><\/pre>\n<p>The query result is still <code>ERROR:  column pg_database.reltuples does not exist<\/code>, indicated by a \u2714 check mark. Next, <code>ORDER BY 1<\/code> is removed, again successfully:<\/p>\n<pre><code>SELECT pg_database.reltuples \/ 1000 FROM pg_database, pg_class WHERE 0 &lt; ((pg_database.reltuples \/ 1000)) \u2714\r\n<\/code><\/pre>\n<p>Now the entire target list is removed:<\/p>\n<pre><code>SELECT FROM pg_database, pg_class WHERE 0 &lt; ((pg_database.reltuples \/ 1000)) \u2714\r\n<\/code><\/pre>\n<p>This shorter query is still equivalent to the original regarding the error message returned when it is run against the database. Now the first unsuccessful reduction step is tried, removing the entire <code>FROM<\/code> clause:<\/p>\n<pre><code>SELECT WHERE 0 &lt; ((pg_database.reltuples \/ 1000)) \u2718 ERROR:  missing FROM-clause entry for table \"pg_database\"\r\n<\/code><\/pre>\n<p>That query is also faulty, but triggers a different error message, so the previous parse tree is kept for the next steps. Again a whole subtree is removed, now the <code>WHERE<\/code> clause:<\/p>\n<pre><code>SELECT FROM pg_database, pg_class \u2718 no error\r\n<\/code><\/pre>\n<p>We have now reduced the input query so much that it doesn&#8217;t error out any more. The previous parse tree is still kept which now looks like this:<\/p>\n<pre><code>selectStmt\r\n\u251c\u2500\u2500 fromClause\r\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 pg_database\r\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 pg_class\r\n\u2514\u2500\u2500 whereClause\r\n \u00a0\u00a0 \u2514\u2500\u2500 &lt;\r\n \u00a0\u00a0     \u251c\u2500\u2500 0\r\n \u00a0\u00a0     \u2514\u2500\u2500 \/\r\n \u00a0\u00a0         \u251c\u2500\u2500 pg_database.reltuples\r\n \u00a0\u00a0         \u2514\u2500\u2500 1000\r\n<\/code><\/pre>\n<p>Now SQLreduce starts digging into the tree. There are several entries in the <code>FROM<\/code> clause, so it tries to shorten the list. First, <code>pg_database<\/code> is removed, but that doesn&#8217;t work, so <code>pg_class<\/code> is removed:<\/p>\n<pre><code>SELECT FROM pg_class WHERE 0 &lt; ((pg_database.reltuples \/ 1000)) \u2718 ERROR:  missing FROM-clause entry for table \"pg_database\"\r\nSELECT FROM pg_database WHERE 0 &lt; ((pg_database.reltuples \/ 1000)) \u2714\r\n<\/code><\/pre>\n<p>Since we have found a new minimal query, recursion restarts at top-level with another try to remove the <code>WHERE<\/code> clause. Since that doesn&#8217;t work, it tries to replace the expression with <code>NULL<\/code>, but that doesn&#8217;t work either.<\/p>\n<pre><code>SELECT FROM pg_database \u2718 no error\r\nSELECT FROM pg_database WHERE NULL \u2718 no error\r\n<\/code><\/pre>\n<p>Now a new kind of step is tried: expression pull-up. We descend into <code>WHERE<\/code> clause, where we replace <code>A &lt; B<\/code> first by <code>A<\/code> and then by <code>B<\/code>.<\/p>\n<pre><code>SELECT FROM pg_database WHERE 0 \u2718 ERROR:  argument of WHERE must be type boolean, not type integer\r\nSELECT FROM pg_database WHERE pg_database.reltuples \/ 1000 \u2714\r\nSELECT WHERE pg_database.reltuples \/ 1000 \u2718 ERROR:  missing FROM-clause entry for table \"pg_database\"\r\n<\/code><\/pre>\n<p>The first try did not work, but the second one did. Since we simplified the query, we restart at top-level to check if the <code>FROM<\/code> clause can be removed, but it is still required.<\/p>\n<p>From <code>A \/ B<\/code>, we can again pull up <code>A<\/code>:<\/p>\n<pre><code>SELECT FROM pg_database WHERE pg_database.reltuples \u2714\r\nSELECT WHERE pg_database.reltuples \u2718 ERROR:  missing FROM-clause entry for table \"pg_database\"\r\n<\/code><\/pre>\n<p>SQLreduce has found the minimal query that still raises <code>ERROR:  column pg_database.reltuples does not exist<\/code> with this parse tree:<\/p>\n<pre><code>selectStmt\r\n\u251c\u2500\u2500 fromClause\r\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 pg_database\r\n\u2514\u2500\u2500 whereClause\r\n \u00a0\u00a0 \u2514\u2500\u2500 pg_database.reltuples\r\n<\/code><\/pre>\n<p>At the end of the run, the query is printed along with some statistics:<\/p>\n<pre><code>Minimal query yielding the same error:\r\nSELECT FROM pg_database WHERE pg_database.reltuples\r\n\r\nPretty-printed minimal query:\r\nSELECT\r\nFROM pg_database\r\nWHERE pg_database.reltuples\r\n\r\nSeen: 15 items, 915 Bytes\r\nIterations: 19\r\nRuntime: 0.107 s, 139.7 q\/s\r\n<\/code><\/pre>\n<p>This minimal query can now be inspected to fix the bug in PostgreSQL or in the application.<\/p>\n<h2>About credativ<\/h2>\n<p>The <a href=\"\/\">credativ GmbH<\/a> is a manufacturer-independent consulting and service company located in Moenchengladbach, Germany. With over 22+ years of development and service experience in the open source space, credativ GmbH can assist you with unparalleled and individually customizable support. We are here to help and assist you in all your open source infrastructure needs.<\/p>\n<p>This article was initially written by Christoph Berg.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQLreduce: Reduce verbose SQL queries to minimal examples Developers often face very large SQL queries that raise some errors. SQLreduce is a tool to reduce that complexity to a minimal query. SQLsmith generates random SQL queries SQLsmith is a tool that generates random SQL queries and runs them against a PostgreSQL server (and other DBMS [&hellip;]<\/p>\n","protected":false},"author":90,"featured_media":6574,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1885,1708],"tags":[1887,1801,1704,1706],"class_list":["post-6529","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos-en","category-postgresql-en","tag-planetpostgresql","tag-postgresql-en","tag-sqlreduce","tag-sqlsmith-en"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.6 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>SQLreduce: Reduce verbose SQL queries to minimal examples - credativ\u00ae<\/title>\n<meta name=\"description\" content=\"Reduce the complexity of your SQL queries with SQLreduce. An effective tool for better development results.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQLreduce: Reduce verbose SQL queries to minimal examples\" \/>\n<meta property=\"og:description\" content=\"Reduce the complexity of your SQL queries with SQLreduce. An effective tool for better development results.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"credativ\u00ae\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/credativDE\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-08T08:30:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-27T18:21:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2022\/03\/in-office-working-on-laptop_2500x300.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2500\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"credativ Redaktion\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@credativde\" \/>\n<meta name=\"twitter:site\" content=\"@credativde\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"credativ Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/\"},\"author\":{\"name\":\"credativ Redaktion\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#\\\/schema\\\/person\\\/63430ac9e022ccceba0f8d53ffe6db12\"},\"headline\":\"SQLreduce: Reduce verbose SQL queries to minimal examples\",\"datePublished\":\"2022-03-08T08:30:35+00:00\",\"dateModified\":\"2026-04-27T18:21:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/\"},\"wordCount\":904,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/in-office-working-on-laptop_2500x300.png\",\"keywords\":[\"planetpostgresql\",\"PostgreSQL\u00ae\",\"SQLreduce\",\"sqlsmith\"],\"articleSection\":[\"HowTos\",\"PostgreSQL\u00ae\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/#respond\"]}],\"copyrightYear\":\"2022\",\"copyrightHolder\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/\",\"name\":\"SQLreduce: Reduce verbose SQL queries to minimal examples - credativ\u00ae\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/in-office-working-on-laptop_2500x300.png\",\"datePublished\":\"2022-03-08T08:30:35+00:00\",\"dateModified\":\"2026-04-27T18:21:41+00:00\",\"description\":\"Reduce the complexity of your SQL queries with SQLreduce. An effective tool for better development results.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/in-office-working-on-laptop_2500x300.png\",\"contentUrl\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/in-office-working-on-laptop_2500x300.png\",\"width\":2500,\"height\":300},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQLreduce: Reduce verbose SQL queries to minimal examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/\",\"name\":\"credativ GmbH\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Organization\",\"Place\"],\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#organization\",\"name\":\"credativ\u00ae\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/\",\"logo\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/#local-main-organization-logo\"},\"image\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/#local-main-organization-logo\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/credativDE\\\/\",\"https:\\\/\\\/x.com\\\/credativde\",\"https:\\\/\\\/mastodon.social\\\/@credativde\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/credativ-gmbh\",\"https:\\\/\\\/www.instagram.com\\\/credativ\\\/\"],\"description\":\"Die credativ GmbH ist ein f\u00fchrendes, auf Open Source Software spezialisiertes IT-Dienstleistungs- und Beratungsunternehmen. Wir bieten umfassende und professionelle Services, von Beratung und Infrastruktur-Betrieb \u00fcber 24\\\/7 Support bis hin zu individuellen L\u00f6sungen und Schulungen. Unser Fokus liegt auf dem ganzheitlichen Management von gesch\u00e4ftskritischen Open-Source-Systemen, darunter Betriebssysteme (z.B. Linux), Datenbanken (z.B. PostgreSQL), Konfigurationsmanagement (z.B. Ansible, Puppet) und Virtualisierung. Als engagierter Teil der Open-Source-Community unterst\u00fctzen wir unsere Kunden dabei, die Vorteile freier Software sicher, stabil und effizient in ihrer IT-Umgebung zu nutzen.\",\"legalName\":\"credativ GmbH\",\"foundingDate\":\"2025-03-01\",\"duns\":\"316387060\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"11\",\"maxValue\":\"50\"},\"address\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/#local-main-place-address\"},\"geo\":{\"@type\":\"GeoCoordinates\",\"latitude\":\"51.1732374\",\"longitude\":\"6.392010099999999\"},\"telephone\":[\"+4921619174200\",\"08002733284\"],\"contactPoint\":{\"@type\":\"ContactPoint\",\"telephone\":\"08002733284\",\"email\":\"vertrieb@credativ.de\"},\"openingHoursSpecification\":[{\"@type\":\"OpeningHoursSpecification\",\"dayOfWeek\":[\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\"],\"opens\":\"09:00\",\"closes\":\"17:00\"},{\"@type\":\"OpeningHoursSpecification\",\"dayOfWeek\":[\"Saturday\",\"Sunday\"],\"opens\":\"00:00\",\"closes\":\"00:00\"}],\"email\":\"info@credativ.de\",\"areaServed\":\"D-A-CH\",\"vatID\":\"DE452151696\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#\\\/schema\\\/person\\\/63430ac9e022ccceba0f8d53ffe6db12\",\"name\":\"credativ Redaktion\",\"description\":\"Dieser Account dient als Sammelpunkt f\u00fcr die wertvollen Beitr\u00e4ge ehemaliger Mitarbeiter von credativ. Wir bedanken uns f\u00fcr ihre gro\u00dfartigen Inhalte, die das technische Wissen in unserem Blog \u00fcber die Jahre hinweg bereichert haben. Ihre Artikel bleiben hier weiterhin f\u00fcr unsere Leser zug\u00e4nglich.\"},{\"@type\":\"PostalAddress\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/#local-main-place-address\",\"streetAddress\":\"Hennes-Weisweiler-Allee 23\",\"addressLocality\":\"M\u00f6nchengladbach\",\"postalCode\":\"41179\",\"addressRegion\":\"Deutschland\",\"addressCountry\":\"DE\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\\\/#local-main-organization-logo\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/credativ-logo-right.svg\",\"contentUrl\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/credativ-logo-right.svg\",\"caption\":\"credativ\u00ae\"}]}<\/script>\n<meta name=\"geo.placename\" content=\"M\u00f6nchengladbach\" \/>\n<meta name=\"geo.position\" content=\"51.1732374;6.392010099999999\" \/>\n<meta name=\"geo.region\" content=\"Germany\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"SQLreduce: Reduce verbose SQL queries to minimal examples - credativ\u00ae","description":"Reduce the complexity of your SQL queries with SQLreduce. An effective tool for better development results.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/","og_locale":"en_US","og_type":"article","og_title":"SQLreduce: Reduce verbose SQL queries to minimal examples","og_description":"Reduce the complexity of your SQL queries with SQLreduce. An effective tool for better development results.","og_url":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/","og_site_name":"credativ\u00ae","article_publisher":"https:\/\/www.facebook.com\/credativDE\/","article_published_time":"2022-03-08T08:30:35+00:00","article_modified_time":"2026-04-27T18:21:41+00:00","og_image":[{"width":2500,"height":300,"url":"https:\/\/www.credativ.de\/wp-content\/uploads\/2022\/03\/in-office-working-on-laptop_2500x300.png","type":"image\/png"}],"author":"credativ Redaktion","twitter_card":"summary_large_image","twitter_creator":"@credativde","twitter_site":"@credativde","twitter_misc":{"Written by":"credativ Editorial Team","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/#article","isPartOf":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/"},"author":{"name":"credativ Redaktion","@id":"https:\/\/www.credativ.de\/en\/#\/schema\/person\/63430ac9e022ccceba0f8d53ffe6db12"},"headline":"SQLreduce: Reduce verbose SQL queries to minimal examples","datePublished":"2022-03-08T08:30:35+00:00","dateModified":"2026-04-27T18:21:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/"},"wordCount":904,"commentCount":0,"publisher":{"@id":"https:\/\/www.credativ.de\/en\/#organization"},"image":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/www.credativ.de\/wp-content\/uploads\/2022\/03\/in-office-working-on-laptop_2500x300.png","keywords":["planetpostgresql","PostgreSQL\u00ae","SQLreduce","sqlsmith"],"articleSection":["HowTos","PostgreSQL\u00ae"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/#respond"]}],"copyrightYear":"2022","copyrightHolder":{"@id":"https:\/\/www.credativ.de\/#organization"}},{"@type":"WebPage","@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/","url":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/","name":"SQLreduce: Reduce verbose SQL queries to minimal examples - credativ\u00ae","isPartOf":{"@id":"https:\/\/www.credativ.de\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/#primaryimage"},"image":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/www.credativ.de\/wp-content\/uploads\/2022\/03\/in-office-working-on-laptop_2500x300.png","datePublished":"2022-03-08T08:30:35+00:00","dateModified":"2026-04-27T18:21:41+00:00","description":"Reduce the complexity of your SQL queries with SQLreduce. An effective tool for better development results.","breadcrumb":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/#primaryimage","url":"https:\/\/www.credativ.de\/wp-content\/uploads\/2022\/03\/in-office-working-on-laptop_2500x300.png","contentUrl":"https:\/\/www.credativ.de\/wp-content\/uploads\/2022\/03\/in-office-working-on-laptop_2500x300.png","width":2500,"height":300},{"@type":"BreadcrumbList","@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.credativ.de\/en\/"},{"@type":"ListItem","position":2,"name":"SQLreduce: Reduce verbose SQL queries to minimal examples"}]},{"@type":"WebSite","@id":"https:\/\/www.credativ.de\/en\/#website","url":"https:\/\/www.credativ.de\/en\/","name":"credativ GmbH","description":"","publisher":{"@id":"https:\/\/www.credativ.de\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.credativ.de\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Organization","Place"],"@id":"https:\/\/www.credativ.de\/en\/#organization","name":"credativ\u00ae","url":"https:\/\/www.credativ.de\/en\/","logo":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/#local-main-organization-logo"},"image":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/#local-main-organization-logo"},"sameAs":["https:\/\/www.facebook.com\/credativDE\/","https:\/\/x.com\/credativde","https:\/\/mastodon.social\/@credativde","https:\/\/www.linkedin.com\/company\/credativ-gmbh","https:\/\/www.instagram.com\/credativ\/"],"description":"Die credativ GmbH ist ein f\u00fchrendes, auf Open Source Software spezialisiertes IT-Dienstleistungs- und Beratungsunternehmen. Wir bieten umfassende und professionelle Services, von Beratung und Infrastruktur-Betrieb \u00fcber 24\/7 Support bis hin zu individuellen L\u00f6sungen und Schulungen. Unser Fokus liegt auf dem ganzheitlichen Management von gesch\u00e4ftskritischen Open-Source-Systemen, darunter Betriebssysteme (z.B. Linux), Datenbanken (z.B. PostgreSQL), Konfigurationsmanagement (z.B. Ansible, Puppet) und Virtualisierung. Als engagierter Teil der Open-Source-Community unterst\u00fctzen wir unsere Kunden dabei, die Vorteile freier Software sicher, stabil und effizient in ihrer IT-Umgebung zu nutzen.","legalName":"credativ GmbH","foundingDate":"2025-03-01","duns":"316387060","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"11","maxValue":"50"},"address":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/#local-main-place-address"},"geo":{"@type":"GeoCoordinates","latitude":"51.1732374","longitude":"6.392010099999999"},"telephone":["+4921619174200","08002733284"],"contactPoint":{"@type":"ContactPoint","telephone":"08002733284","email":"vertrieb@credativ.de"},"openingHoursSpecification":[{"@type":"OpeningHoursSpecification","dayOfWeek":["Monday","Tuesday","Wednesday","Thursday","Friday"],"opens":"09:00","closes":"17:00"},{"@type":"OpeningHoursSpecification","dayOfWeek":["Saturday","Sunday"],"opens":"00:00","closes":"00:00"}],"email":"info@credativ.de","areaServed":"D-A-CH","vatID":"DE452151696"},{"@type":"Person","@id":"https:\/\/www.credativ.de\/en\/#\/schema\/person\/63430ac9e022ccceba0f8d53ffe6db12","name":"credativ Redaktion","description":"Dieser Account dient als Sammelpunkt f\u00fcr die wertvollen Beitr\u00e4ge ehemaliger Mitarbeiter von credativ. Wir bedanken uns f\u00fcr ihre gro\u00dfartigen Inhalte, die das technische Wissen in unserem Blog \u00fcber die Jahre hinweg bereichert haben. Ihre Artikel bleiben hier weiterhin f\u00fcr unsere Leser zug\u00e4nglich."},{"@type":"PostalAddress","@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/#local-main-place-address","streetAddress":"Hennes-Weisweiler-Allee 23","addressLocality":"M\u00f6nchengladbach","postalCode":"41179","addressRegion":"Deutschland","addressCountry":"DE"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/sqlreduce-reduce-verbose-sql-queries-to-minimal-examples\/#local-main-organization-logo","url":"https:\/\/www.credativ.de\/wp-content\/uploads\/2025\/04\/credativ-logo-right.svg","contentUrl":"https:\/\/www.credativ.de\/wp-content\/uploads\/2025\/04\/credativ-logo-right.svg","caption":"credativ\u00ae"}]},"geo.placename":"M\u00f6nchengladbach","geo.position":{"lat":"51.1732374","long":"6.392010099999999"},"geo.region":"Germany"},"_links":{"self":[{"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/posts\/6529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/users\/90"}],"replies":[{"embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/comments?post=6529"}],"version-history":[{"count":3,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/posts\/6529\/revisions"}],"predecessor-version":[{"id":18734,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/posts\/6529\/revisions\/18734"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/media\/6574"}],"wp:attachment":[{"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/media?parent=6529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/categories?post=6529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/tags?post=6529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}