{"id":2332,"date":"2014-09-24T12:58:40","date_gmt":"2014-09-24T12:58:40","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=2332"},"modified":"2014-09-24T12:58:40","modified_gmt":"2014-09-24T12:58:40","slug":"postgres-time-travelling-debugger","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/","title":{"rendered":"Postgres: Time Travelling Debugger"},"content":{"rendered":"<p>Imagine you\u2019re an engineer doing phone support for Netflix. The movies they show change regularly:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.garysieling.com\/blog\/wp-content\/uploads\/2014\/09\/netflix7-578x142.png\" alt=\"netflix7\" width=\"578\" height=\"142\" class=\"aligncenter size-large wp-image-2359\" \/><\/p>\n<p>There are various reasons for this \u2013 Netflix suddenly thinks you like period pieces, or they get into a contract dispute with one of their vendors.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.garysieling.com\/blog\/wp-content\/uploads\/2014\/09\/netflix9-578x142.png\" alt=\"netflix9\" width=\"578\" height=\"142\" class=\"aligncenter size-large wp-image-2360\" \/><\/p>\n<p>As a support engineer, this presents a set of communication challenges, which inspire some technical solutions. Customers often ask questions like \u201cwhy is this different than a week ago?\u201d It&#8217;s a reasonable question, but very time consuming to answer. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.garysieling.com\/blog\/wp-content\/uploads\/2014\/09\/netflix10-578x160.png\" alt=\"netflix10\" width=\"578\" height=\"160\" class=\"aligncenter size-large wp-image-2361\" \/><\/p>\n<p>To make this easier, we need to <a href=\"http:\/\/www.garysieling.com\/blog\/auditing-data-changes-postgres\">store the audit history of this data<\/a>, and write a view that shows the full information available about a movie over time. <\/p>\n<p>For this example, we define a simple schema, with movie and their associated licenses.<\/p>\n<pre lang=\"sql\">\ncreate table movies (\n  id int primary key, \n  title text);\n\ncreate table licenses (\n  id int primary key,\n  movie_id int references movies (id),\n  title text, \n  start_date timestamp, \n  end_date timestamp\n);\n<\/pre>\n<p>The example database maintains audit history, which stores every change that has happened over time:<\/p>\n<pre lang=\"sql\">\ncreate table movies$a (\n  id int, \n  title text, \n  audit_txid bigint,\n  audit_date timestamp with time zone);\n\ncreate table licenses$a (\n  id int,\n  movie_id int references movies (id),\n  title text, \n  start_date timestamp, \n  end_date timestamp,\n  audit_txid bigint,\n  audit_date timestamp with time zone\n);\n<\/pre>\n<p>Given this, we want to write a view that shows everything about a movie, including an &#8216;effective&#8217; time interval. If we include an interval in the view, we can filter to a specific time, as shown below (the <@ operator is 'contains')\n\n\n\n<pre lang=\"sql\">\nselect\n  id, movie_title, license_start, license_end\nfrom\n  movie_history_vw\nwhere \n  effective <@ (now() - interval '1 day')\n<\/pre>\n<p>The first step is to generate effective date ranges for rows in the movie and license tables. The &#8216;tsrange&#8217; function creates intervals from the time of a change and the subsequent change &#8211; the last argument shows that it is closed on one end and open on the other. If we find the most recent change, we say it\u2019s effective until infinity:<\/p>\n<pre lang=\"sql\">\nselect\n  m.id, m.title,\n  tstzrange(\n    coalesce(m.audit_date, '-infinity'), \n    coalesce(lead(m.audit_date) over w_m, 'infinity'),\n    '[)'\n  ) movie_effective \nfrom movies$a m\nwindow w_m as (partition by m.id order by m.audit_date asc)\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.garysieling.com\/blog\/wp-content\/uploads\/2014\/09\/debugger-1-578x126.png\" alt=\"debugger-1\" width=\"578\" height=\"126\" class=\"aligncenter size-large wp-image-2351\" \/><\/p>\n<pre lang=\"sql\">\nselect\n  l.id, l.title, movie_id,\n  tstzrange(\n    coalesce(l.audit_date, '-infinity'), \n    coalesce(lead(l.audit_date) over w_l, 'infinity'),\n    '[)'\n  ) license_effective  \nfrom licenses$a l\nwindow w_l as (partition by l.id order by l.audit_date asc)\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.garysieling.com\/blog\/wp-content\/uploads\/2014\/09\/debugger-2-578x54.png\" alt=\"debugger-2\" width=\"578\" height=\"54\" class=\"aligncenter size-large wp-image-2352\" \/><\/p>\n<p>Once we have effective date ranges for each relevant entity, we need to join the two histories on the foreign key relationship. Since the license is optional, we set it&#8217;s effective range to all of time, to make the next step easier:<\/p>\n<pre lang=\"sql\">\nwith movies_history as (...),\nlicenses_history as (...)\nselect m.id, m.title, l.id, l.title,\n  movie_effective,\n  coalesce(l.license_effective, '[-infinity,infinity]') license_effective\nfrom movies_history m\nleft join licenses_history l\non l.movie_id = m.id\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.garysieling.com\/blog\/wp-content\/uploads\/2014\/09\/debugger-3-578x121.png\" alt=\"debugger-3\" width=\"578\" height=\"121\" class=\"aligncenter size-large wp-image-2353\" \/><\/p>\n<p>Now we can filter the results to only include rows where the license and movie were effective at the same time. <\/p>\n<p>The &#8220;&#038;&#038;&#8221; operator checks for overlapping intervals, and the &#8220;*&#8221; operator finds the minimum interval:<\/p>\n<pre lang=\"sql\">\nwith movies_history as (...),\n     licenses_history as (...),\n     joined_history as (...)\nselect \n  movie_id, movie_title, license_id, license_title,\n  movie_effective * license_effective effective\nfrom joined_history\nwhere movie_effective && license_effective\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.garysieling.com\/blog\/wp-content\/uploads\/2014\/09\/debugger-4-578x63.png\" alt=\"debugger-4\" width=\"578\" height=\"63\" class=\"aligncenter size-large wp-image-2354\" \/><\/p>\n<p>From this, we can now generate the query as desired, which filters to values effeffective at a specific time yesterday:<\/p>\n<pre lang=\"sql\">\ncreate view movie_history_vw as \nwith movies_history as (...),\n     licenses_history as (...),\n     joined_history as (...)\nwhere movie_effective @> (now() - interval '1 day')\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.garysieling.com\/blog\/wp-content\/uploads\/2014\/09\/debugger-5-578x61.png\" alt=\"debugger-5\" width=\"578\" height=\"61\" class=\"aligncenter size-large wp-image-2355\" \/><\/p>\n<p>If you want to provide more parameters, it can be valuable to embed this query in a stored procedure, and use the stored procedure as a view that takes parameters, as shown below:<\/p>\n<pre lang=\"sql\">\ncreate or replace function movie_history(timestamp with time zone) \nreturns setof movie_history_vw as \n$$\ndeclare\n  r record;\n  query text;\nbegin\n  return query\n    select * \n    from movie_history_vw \n    where license_effective @> $1 \nend\n$$ language 'plpgsql';\n\nselect * from movie_history(now() - interval '1 day');\n<\/pre>\n<p>For the full solution to this, we need to generate the above views &#8211; once it includes dozens of tables, it is far too complex to hand-write. <\/p>\n<p>If you want to do this with plpgsql, the format function works nicely, as it supports multi-line strings and can format identifiers for you:<\/p>\n<pre lang=\"sql\">\ntable_sql := \n  format(\n    '-- audit table creation\ncreate table %s$a\n     as select t.*, \n       null::text(1) audit_action,\n       null::text audit_request,\n       null::bigint audit_txid,\n       null::text audit_user, \n       null::timestamp audit_date\n     from %I t \n     where 0 = 1',\n     table_name,\n     table_name\n);\n<\/pre>\n<p>The full solution to generate the audit tables and the history view is included in the <a href=\"https:\/\/github.com\/wingspan\/wingspan-auditing\/blob\/master\/analysis\/history.sql\">wingspan-auditing<\/a> library.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Imagine you\u2019re an engineer doing phone support for Netflix. The movies they show change regularly: There are various reasons for this \u2013 Netflix suddenly thinks you like period pieces, or they get into a contract dispute with one of their vendors. As a support engineer, this presents a set of communication challenges, which inspire some &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Postgres: Time Travelling Debugger&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4,6],"tags":[85,140,149,155,157,437],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"Imagine you\u2019re an engineer doing phone support for Netflix. The movies they show change regularly: There are various reasons for this \u2013 Netflix suddenly thinks you like period pieces, or they get into a contract dispute with one of their vendors. As a support engineer, this presents a set of communication challenges, which inspire some\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"gary\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Gary Sieling - Software Engineer\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Postgres: Time Travelling Debugger - Gary Sieling\" \/>\n\t\t<meta property=\"og:description\" content=\"Imagine you\u2019re an engineer doing phone support for Netflix. The movies they show change regularly: There are various reasons for this \u2013 Netflix suddenly thinks you like period pieces, or they get into a contract dispute with one of their vendors. As a support engineer, this presents a set of communication challenges, which inspire some\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2014-09-24T12:58:40+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2014-09-24T12:58:40+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Postgres: Time Travelling Debugger - Gary Sieling\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Imagine you\u2019re an engineer doing phone support for Netflix. The movies they show change regularly: There are various reasons for this \u2013 Netflix suddenly thinks you like period pieces, or they get into a contract dispute with one of their vendors. As a support engineer, this presents a set of communication challenges, which inspire some\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/postgres-time-travelling-debugger\\\/#blogposting\",\"name\":\"Postgres: Time Travelling Debugger - Gary Sieling\",\"headline\":\"Postgres: Time Travelling Debugger\",\"author\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"http:\\\/\\\/www.garysieling.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/netflix7-578x142.png\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/postgres-time-travelling-debugger\\\/#articleImage\"},\"datePublished\":\"2014-09-24T12:58:40+00:00\",\"dateModified\":\"2014-09-24T12:58:40+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/postgres-time-travelling-debugger\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/postgres-time-travelling-debugger\\\/#webpage\"},\"articleSection\":\"Code Examples, Data Science, big data, data analysis, data quality assurance, data visualization tools free, database, postgres\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/postgres-time-travelling-debugger\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.garysieling.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/category\\\/code-examples\\\/#listItem\",\"name\":\"Code Examples\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/category\\\/code-examples\\\/#listItem\",\"position\":2,\"name\":\"Code Examples\",\"item\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/category\\\/code-examples\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/postgres-time-travelling-debugger\\\/#listItem\",\"name\":\"Postgres: Time Travelling Debugger\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/postgres-time-travelling-debugger\\\/#listItem\",\"position\":3,\"name\":\"Postgres: Time Travelling Debugger\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/category\\\/code-examples\\\/#listItem\",\"name\":\"Code Examples\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#organization\",\"name\":\"Gary Sieling\",\"description\":\"Software Engineer\",\"url\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/#author\",\"url\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/\",\"name\":\"gary\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/postgres-time-travelling-debugger\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0be925276d848ffe98a6a9dc8cf33e67?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"gary\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/postgres-time-travelling-debugger\\\/#webpage\",\"url\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/postgres-time-travelling-debugger\\\/\",\"name\":\"Postgres: Time Travelling Debugger - Gary Sieling\",\"description\":\"Imagine you\\u2019re an engineer doing phone support for Netflix. The movies they show change regularly: There are various reasons for this \\u2013 Netflix suddenly thinks you like period pieces, or they get into a contract dispute with one of their vendors. As a support engineer, this presents a set of communication challenges, which inspire some\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/postgres-time-travelling-debugger\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/#author\"},\"datePublished\":\"2014-09-24T12:58:40+00:00\",\"dateModified\":\"2014-09-24T12:58:40+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/\",\"name\":\"Gary Sieling\",\"description\":\"Software Engineer\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Postgres: Time Travelling Debugger - Gary Sieling","description":"Imagine you\u2019re an engineer doing phone support for Netflix. The movies they show change regularly: There are various reasons for this \u2013 Netflix suddenly thinks you like period pieces, or they get into a contract dispute with one of their vendors. As a support engineer, this presents a set of communication challenges, which inspire some","canonical_url":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/#blogposting","name":"Postgres: Time Travelling Debugger - Gary Sieling","headline":"Postgres: Time Travelling Debugger","author":{"@id":"https:\/\/www.garysieling.com\/blog\/author\/gary\/#author"},"publisher":{"@id":"https:\/\/www.garysieling.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"http:\/\/www.garysieling.com\/blog\/wp-content\/uploads\/2014\/09\/netflix7-578x142.png","@id":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/#articleImage"},"datePublished":"2014-09-24T12:58:40+00:00","dateModified":"2014-09-24T12:58:40+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/#webpage"},"isPartOf":{"@id":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/#webpage"},"articleSection":"Code Examples, Data Science, big data, data analysis, data quality assurance, data visualization tools free, database, postgres"},{"@type":"BreadcrumbList","@id":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.garysieling.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/category\/code-examples\/#listItem","name":"Code Examples"}},{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/category\/code-examples\/#listItem","position":2,"name":"Code Examples","item":"https:\/\/www.garysieling.com\/blog\/category\/code-examples\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/#listItem","name":"Postgres: Time Travelling Debugger"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/#listItem","position":3,"name":"Postgres: Time Travelling Debugger","previousItem":{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/category\/code-examples\/#listItem","name":"Code Examples"}}]},{"@type":"Organization","@id":"https:\/\/www.garysieling.com\/blog\/#organization","name":"Gary Sieling","description":"Software Engineer","url":"https:\/\/www.garysieling.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.garysieling.com\/blog\/author\/gary\/#author","url":"https:\/\/www.garysieling.com\/blog\/author\/gary\/","name":"gary","image":{"@type":"ImageObject","@id":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/0be925276d848ffe98a6a9dc8cf33e67?s=96&d=identicon&r=g","width":96,"height":96,"caption":"gary"}},{"@type":"WebPage","@id":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/#webpage","url":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/","name":"Postgres: Time Travelling Debugger - Gary Sieling","description":"Imagine you\u2019re an engineer doing phone support for Netflix. The movies they show change regularly: There are various reasons for this \u2013 Netflix suddenly thinks you like period pieces, or they get into a contract dispute with one of their vendors. As a support engineer, this presents a set of communication challenges, which inspire some","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.garysieling.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/#breadcrumblist"},"author":{"@id":"https:\/\/www.garysieling.com\/blog\/author\/gary\/#author"},"creator":{"@id":"https:\/\/www.garysieling.com\/blog\/author\/gary\/#author"},"datePublished":"2014-09-24T12:58:40+00:00","dateModified":"2014-09-24T12:58:40+00:00"},{"@type":"WebSite","@id":"https:\/\/www.garysieling.com\/blog\/#website","url":"https:\/\/www.garysieling.com\/blog\/","name":"Gary Sieling","description":"Software Engineer","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.garysieling.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Gary Sieling - Software Engineer","og:type":"article","og:title":"Postgres: Time Travelling Debugger - Gary Sieling","og:description":"Imagine you\u2019re an engineer doing phone support for Netflix. The movies they show change regularly: There are various reasons for this \u2013 Netflix suddenly thinks you like period pieces, or they get into a contract dispute with one of their vendors. As a support engineer, this presents a set of communication challenges, which inspire some","og:url":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/","article:published_time":"2014-09-24T12:58:40+00:00","article:modified_time":"2014-09-24T12:58:40+00:00","twitter:card":"summary_large_image","twitter:title":"Postgres: Time Travelling Debugger - Gary Sieling","twitter:description":"Imagine you\u2019re an engineer doing phone support for Netflix. The movies they show change regularly: There are various reasons for this \u2013 Netflix suddenly thinks you like period pieces, or they get into a contract dispute with one of their vendors. As a support engineer, this presents a set of communication challenges, which inspire some"},"aioseo_meta_data":{"post_id":"2332","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2023-02-04 16:26:29","updated":"2026-07-06 01:11:44","ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.garysieling.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.garysieling.com\/blog\/category\/code-examples\/\" title=\"Code Examples\">Code Examples<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tPostgres: Time Travelling Debugger\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.garysieling.com\/blog"},{"label":"Code Examples","link":"https:\/\/www.garysieling.com\/blog\/category\/code-examples\/"},{"label":"Postgres: Time Travelling Debugger","link":"https:\/\/www.garysieling.com\/blog\/postgres-time-travelling-debugger\/"}],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2332"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=2332"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2332\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=2332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=2332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=2332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}