{"id":46566,"date":"2018-03-27T00:00:00","date_gmt":"2018-03-27T07:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/blog\/migrating-from-postgresql-to-griddb\/"},"modified":"2025-11-13T12:54:33","modified_gmt":"2025-11-13T20:54:33","slug":"migrating-from-postgresql-to-griddb","status":"publish","type":"post","link":"https:\/\/www.griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/","title":{"rendered":"Migrating from PostgreSQL to GridDB"},"content":{"rendered":"<h2 id=\"intro\">Introduction<\/h2>\n<p>In one of our <a href=\"https:\/\/griddb.net\/en\/blog\/migrating-from-mysql-to-griddb\/#migration\">past posts<\/a>, we migrated the relational database MySQL using Java. In this post we will continue a similar trend by showing step-by-step how to migrate an existing <a href=\"https:\/\/postgresql.org\" title=\"PostgreSQL homepage\">PostgreSQL database<\/a> to a GridDB cluster with Python.<br \/>\n<a href=\"https:\/\/www.postgresql.org\/\" title=\"PostgreSQL Website\">Postgresql<\/a> is a relational database that has been widely used in business intelligence, web development, commerce, healthcare, and biopharmacy. While PostgreSQL offers several benefits, it still suffers from the same disadvantages as many other relational databases. Some of these include poor scalability and a lack of flexibility. PostgreSQL can also have a steep learning curve and have worse performance when handling certain datasets.<br \/>\nGridDB on the other hand will provide the great horizontal <a href=\"https:\/\/griddb.net\/en\/docs\/documents\/1-1_what-is-griddb.php#sec-1.1\">scalability<\/a> and flexibility of a NoSQL database. It also provides <i>ACID compliance<\/i> along with high <a href=\"https:\/\/griddb.net\/en\/docs\/GridDB_Reliability_and_Robustness_1.0.7.pdf?x21046\" title=\"GridDB Reliability Whitepaper\">reliability<\/a> and <a href=\"https:\/\/griddb.net\/en\/docs\/documents\/3-8_replication-distribution.php\" title=\"GridDB Replication\">availabilty<\/a>. GridDB also gives superior performance with an in-memory architecture, making it perfect for many applications, namely IoT applications.<\/p>\n<h3 id=\"use-case\">Use Case<\/h3>\n<p>To make things simple, we will use the same industry example as our last migration. The scenario will be a  <a href=\"https:\/\/griddb.net\/en\/docs\/manuals\/v3.1\/GridDB_ProgrammingTutorial.html\" title=\"Details of a PV Site\"><b>photovoltaic<\/b> site <\/a> (PV) which can be thought of as an industrial <b>solar farm<\/b>. Most of the data in this database will relate to information and measurements sent by sensors and the facilities they are contained in.<\/p>\n<h3 id=\"griddb-model\">GridDB Data Model<\/h3>\n<p>Since PostgreSQL is a <i>relational<\/i> database very similar to Oracle Database and MySQL, we will be using the same example database as last time. Therefore our schema for the PostgreSQL database will be the same. Our GridDB data model will also be the same as before, only that we will be creating and populating our database using a <b>Python API<\/b>.<\/p>\n<p>There will be <b>4 tables<\/b> in the PostgreSQL database which will translate into <b>4 container schemas<\/b> in GridDB. They are detailed below.<\/p>\n<ol id=\"schemas\">\n<li><b>Facilities:<\/b> Contains information and specifications for the facilities of the PV site.<\/li>\n<p><\/p>\n<div style=display: block;\">\n<div style=\"width: 50%; float: left;\">\n<div style=\"text-align: center;width: 90%\"><b>PostgreSQL Facilities Table<\/b><\/div>\n<p><\/p>\n<pre class=\"prettyprint\" style=\"width: 90%;\">\nCREATE TABLE IF NOT EXISTS facilities (\n\tfacilityId VARCHAR(20) PRIMARY KEY,\n\tname VARCHAR(50) NOT NULL,\n\tspecifications BYTEA\n);\n           <\/pre>\n<\/p><\/div>\n<div style=\"width: 50%; float: left;\">\n<div style=\"width: 90%; text-align: center;\"><b>GridDB Facility Container Schema<\/b><\/div>\n<p><\/p>\n<pre class=\"prettyprint\" style=\"width: 90%;\">\nfacilities = gridstore.put_container(\"facilities\",\n                        [(\"facilityId\",griddb.GS_TYPE_STRING),\n\t\t\t(\"name\",griddb.GS_TYPE_STRING),\n                        (\"specifications\",griddb.GS_TYPE_BLOB)],\n\t\t\tgriddb.GS_CONTAINER_COLLECTION)\n           <\/pre>\n<\/p><\/div>\n<div style=\"clear: both;\">&nbsp;<\/div>\n<\/p><\/div>\n<li><b>Sensor:<\/b> Stores general information like <i>sensor-type<\/i> and name on the PV site&#8217;s sensors<\/li>\n<p><\/p>\n<div style=\"display: block;\">\n<div style=\"width: 50%;float: left;\">\n<div style=\"text-align:center; width: 90%;\"><b>PostgreSQL Sensor Table<\/b><\/div>\n<p><\/p>\n<pre class=\"prettyprint\" style=\"width: 90%;\">\nCREATE TABLE IF NOT EXISTS sensors (\n\tsensorId VARCHAR(40) PRIMARY KEY,\n\tfacilityId VARCHAR(20) REFERENCES facilities(facilityId)\n           ON DELETE CASCADE ON UPDATE CASCADE,\n\tname VARCHAR(50) NOT NULL,\n\ttype VARCHAR(50) NOT NULL\n);\n          <\/pre>\n<\/p><\/div>\n<div style=\"width: 50%; float:left;\">\n<div style=\"text-align: center;width: 90%;\"><b>GridDB Sensor Container Schema<\/b><\/div>\n<p><\/p>\n<pre class=\"prettyprint\" style=\"width: 90%;\">\nfacility = gridstore.put_container(\"facility_1\",\n                [(\"sensorId\",griddb.GS_TYPE_STRING),\n\t\t(\"name\",griddb.GS_TYPE_STRING),\n                (\"type\",griddb.GS_TYPE_STRING)],\n                 griddb.GS_CONTAINER_COLLECTION)\n           <\/pre>\n<\/p><\/div>\n<div style=\"clear: both;\">&nbsp;<\/div>\n<\/p><\/div>\n<li><b>Readings:<\/b> Stores the <i>timestamps and values<\/i> of the measurements recorded by the PV site&#8217;s sensors<\/li>\n<p><\/p>\n<div style=\"display: block;\">\n<div style=\"width: 50%;float: left;\">\n<div style=\"text-align: center; width: 90%;\"><b>PostgreSQL Reading Table<\/b><\/div>\n<p><\/p>\n<pre class=\"prettyprint\" style=\"width: 90%;\">\nCREATE TABLE IF NOT EXISTS readings (\n\trecordId SERIAL PRIMARY KEY,\n\tsensorId VARCHAR(40) REFERENCES sensors(sensorId)\n            ON DELETE CASCADE ON UPDATE CASCADE,\n\tts TIMESTAMP DEFAULT NOW() NOT NULL,\n\tvalue REAL NOT NULL,\n\tstatus VARCHAR(255) NOT NULL\n);\n            <\/pre>\n<\/p><\/div>\n<div style=\"width: 50%;float: left;\">\n<div style=\"text-align: center;width: 90%;\"><b>GridDB Reading Container Schema<\/b><\/div>\n<p><\/p>\n<pre class=\"prettyprint\" style=\"width: 90%;\">\ntimeseries = gridstore.put_container(\"sensor_1\",\n                [(\"timestamp\",griddb.GS_TYPE_TIMESTAMP),\n\t\t(\"value\",griddb.GS_TYPE_DOUBLE),\n                (\"status\",griddb.GS_TYPE_STRING)],\n\t\tgriddb.GS_CONTAINER_TIME_SERIES)\n            <\/pre>\n<\/p><\/div>\n<div style=\"clear: both;\">&nbsp;<\/div>\n<\/p><\/div>\n<li><b>Alerts:<\/b> Stores information related to <i>alerts and notifications<\/i> sent by the sensors<\/li>\n<p><\/p>\n<div style=\"display: block;\">\n<div style=\"width: 50%;float: left;\">\n<div style=\"text-align: center;width: 90%;\"><b>PostgreSQL Alerts Table<\/b><\/div>\n<p><\/p>\n<pre class=\"prettyprint\" style=\"width: 90%;\">\nCREATE TABLE IF NOT EXISTS alerts (\n\talertId SERIAL PRIMARY KEY,\n\tts TIMESTAMP DEFAULT NOW() NOT NULL,\n\tfacilityId VARCHAR(20) REFERENCES facilities(facilityId)\n            ON DELETE CASCADE ON UPDATE CASCADE,\n\tsensorId VARCHAR(40) REFERENCES sensors(sensorId)\n            ON DELETE CASCADE ON UPDATE CASCADE,\n\tlevel INT NOT NULL,\n\tdetail VARCHAR(255) NOT NULL\n);\n            <\/pre>\n<\/p><\/div>\n<div style=\"width: 50%;float: left;\">\n<div style=\"text-align: center;width: 90%;\"><b>GridDB Alerts Container Schema<\/b><\/div>\n<p><\/p>\n<pre class=\"prettyprint\" style=\"width: 90%;\">\nalerts_col = gridstore.put_container(\"alerts\",\n                [(\"id\",griddb.GS_TYPE_INTEGER),\n\t\t(\"timestamp\",griddb.GS_TYPE_TIMESTAMP),\n                (\"facilityId\",griddb.GS_TYPE_STRING),\n\t\t(\"sensorId\",griddb.GS_TYPE_STRING),\n                (\"level\",griddb.GS_TYPE_INTEGER),\n                (\"detail\",griddb.GS_TYPE_STRING)],\n\t\tgriddb.GS_CONTAINER_COLLECTION)\n            <\/pre>\n<\/p><\/div>\n<div style=\"clear: both;\">&nbsp;<\/div>\n<\/p><\/div>\n<\/ol>\n<h3 id=\"migration\">Performing the Migration<\/h3>\n<p>Now that we have our schemas and data models setup for both PostgreSQL and GridDB, we can now perform our data migration. We will <code>SELECT<\/code> all the <i>rows<\/i> from each PostgreSQL table, reformat and rearrange into a GridDB <code>Row<\/code>. To follow, we will then insert that row into its corresponding <code>Collection<\/code> or <code>Timeseries<\/code> container.<br \/>\nFor reference, the PostgreSQL database being migrated is named <code>'pv'<\/code>.<\/p>\n<h4 id=\"python-apis\">Installing the Python APIs and Connectors<\/h4>\n<p>First off, we will need the <a href=\"https:\/\/pypi.python.org\/pypi\/psycopg2\">psycopg2 package<\/a> to use Python with PostgreSQL. We will also need the <a href=\"https:\/\/pypi.python.org\/pypi\/griddb-python-client\" title=\"GridDB Python package\">griddb_python_client package<\/a> to access GridDB from Python. You can install both of these packages using the <code>pip<\/code> package installer.<\/p>\n<pre class=\"prettyprint\">\n$ python -m pip install psycopg2\n$ python -m pip install griddb_python_client\n<\/pre>\n<p>Once installed we can connect to our <i>pv<\/i> database in PostgreSQL <a href=\"https:\/\/wiki.postgresql.org\/wiki\/Using_psycopg2_with_PostgreSQL#Connect_to_Postgres\" title=\"Connect to PostgreSQL using Python\">using pscycopg2<\/a>. We will connect to our GridDB cluster <a href=\"https:\/\/griddb.net\/en\/blog\/using-griddbs-cpythonruby-apis\/#connect-python\" title=\"Connecting to GridDB with Python\">with Python<\/a>.<\/p>\n<h4 id=\"migrate-facilities\">Migrating the Facilities Table<\/h4>\n<p>Once we have our <code>Collection<\/code> container formed in GridDB for storing facilities, we can then access and migrate all the rows from the <b>facilities<\/b> table in PostgreSQL. To begin, we obtain a <code>row cursor<\/code> from the facilities table in PostgreSQL. A <code>row cursor<\/code> returns an <b>array<\/b> of one row&#8217;s <b>column values<\/b>.<br \/>\nAll the column values are translated to their <i>appropriate types<\/i> in Python. This means no additional parsing or type-conversion of the values is necessary. All the individual values of the row can be obtained as long as you create <i>the correct amount of variables<\/i> for the <b>number of columns<\/b> returned for each row.<br \/>\nOnce we have all the row&#8217;s column values, we can create a GridDB row-object and set all the <code>row fields<\/code> accordingly. Type conversion between the databases is handled this way for types like strings and numerics. The only thing to note is that the <code>BLOB<\/code> value from PostgreSQL should be converted to a <code>bytearray<\/code> before being inserted into the GridDB <a href=\"https:\/\/griddb.net\/en\/docs\/documents\/3-2_key-container-model.php#sec-1.1\" title=\"Collections in GridDB\">collection<\/a>.<\/p>\n<pre class=\"prettyprint\">\nquery = \"SELECT * FROM facilites\"\ncursor = connection.cursor() #Obtain row cursor from PostgreSQL connection\ncursor.execute(query)\nrow = cursor.fetchone()\nwhile row is not None:\n        ## Get all id, name, and specification column values from row\n        facility_id, name, blob = row\n        facility_row = facilities.create_row()\n        facility_row.set_field_by_string(0,facility_id)\n        facility_row.set_field_by_string(1,name)\n        facility_row.set_field_by_blob(2,bytearray(blob)) ## Convert Blob data to bytearray\n        ret = facilities.put_row(facility_row)\n<\/pre>\n<h4 id=\"migrate-sensors\">Migrating Sensor Data<\/h4>\n<p>During the migration of the <i>facilities<\/i> table, we obtain the <code>facility_id<\/code> of every facility in the database. With that facility id, we can create a <code>sensor_collection<\/code> for that facility to store information on its sensors.<br \/>\nFirst, we must get every row in the <code>sensors<\/code> table in PostgreSQL that has the <b>facility id<\/b>. Since our rows in our <b>Sensor<\/b> containers in GridDB do not have <i>facility_id<\/i> columns, there is no need to fetch those columns from PostgreSQL.<br \/>\nNow that we have created our <i>Collection container<\/i> for a facility&#8217;s sensors, we can go through the same process of parsing the PostgreSQL rows and inserting them into the facility&#8217;s <i>Collection<\/i> in GridDB.<\/p>\n<pre class=\"prettyprint\">\nfacility = \"facility_1\"\nquery = \"SELECT sensorId,name,type FROM sensors WHERE facilityId='%s'\" % (facility)\ncursor = connection.cursor()\ncursor.execute(query)\nrow = cursor.fetchone()\nwhile row is not None:\n        sensor_id, name, sensor_type = row\n        sensor = sensor_collection.create_row()\n        sensor.set_field_by_string(0,sensor_id)\n        sensor.set_field_by_string(1,name)\n        sensor.set_field_by_string(2,sensor_type)\n        ret = sensor_collection.put_row(sensor)\n<\/pre>\n<h4 id=\"migrate-readings\">Migrating Sensor Readings<\/h4>\n<p>Because we get the <code>sensor_id<\/code> of each sensor when migrating the <i>sensors<\/i> PostgreSQL table, we also create a <code>Timeseries<\/code> container for that sensor to store the sensor&#8217;s recorded measurements. All that needs to be done is to <code>SELECT<\/code> all the rows from the <b>readings<\/b> table with that <i>sensor-id<\/i>. Because <a href=\"https:\/\/griddb.net\/en\/docs\/documents\/3-2_key-container-model.php#sec-1.2\" title=\"Timeseries containers in GridDB\">timeseries<\/a> containers have timestamps as their <b>row-keys<\/b>, we will order the rows obtained from PostgreSQL by the <code>TIMESTAMP<\/code> column.<br \/>\nJust with all the rows in all the <i>past<\/i> tables, we go through the same process of retrieving all the column values so they can be set as <i>row-fields<\/i> in a GridDB row.<br \/>\nOne thing to note is that <code>TIMESTAMP<\/code>, <code>DATE<\/code>, and <code>TIME<\/code> column values in PostgreSQL are returned as <code>datetime<\/code> values in Python. <b>Timestamp<\/b> columns, or row-fields, in GridDB, can only be set in a <i>numerical<\/i> format. As a result, the <i>datetime<\/i> object must be converted to a timestamp number. Once the conversion is complete, we can then set all the <i>row-fields<\/i> and insert the row into the <b>Timeseries<\/b> container for that sensor in GridDB.<\/p>\n<pre class=\"prettyprint\">\ngriddb = griddb_python_client\ndef datetime_to_timestamp(dt):\n        ## GridDB Timestamp Format: (All fields must be numerics)\n        ## $YEAR-$MONTH-$DAYT$HOUR:$MINUTE:$SECONDZ\n        time_string = dt.strftime(\"%Y-%m-%dT%XZ\") # '%X' means get timestamp value from 'datetime'\n        timestamp = griddb.Timestamp_parse(time_string)\n        return timestamp\n## (snip)\n## Migrate data from 'readings' table from PostgreSQL into Timeseries containers in GridDB\nsensor_id = \"sensor_1\" ## Example of a sensor id in a PV Site's facility\nquery = \"SELECT ts,value,status FROM sensors WHERE sensor_id = '%s' ORDER BY ts ASC\" % (sensor_id)\ncursor = connection.cursor()\ncursor.execute(query)\nrow = cursor.fetchone()\n## Obtain column values from each reading row (sensor measurement) from 'readings table\nwhile row is not None:\n        date, value, status = row\n        reading = timeseries.create_row()\n        timestamp = datetime_to_timestamp(date)\n        reading.set_field_by_timestamp(0,timestamp)\n        reading.set_field_by_double(1,value)\n        reading.set_field_by_string(2,status)\n        ret = timeseries.put_row(reading)\n<\/pre>\n<h4 id=\"migrate-alerts\">Migrating the Alerts Table<\/h4>\n<p>The <code>alerts<\/code> table in PostgreSQL table will only be mapped to <b>1 collection container<\/b> in GridDB. As a result, the migration process will be similar to the <b>facilities<\/b> table.<\/p>\n<pre class=\"prettyprint\">\nquery = \"SELECT * FROM alerts\"\ncursor = connection.cursor()\ncursor.execute(query)\nrow = cursor.fetchone()\nwhile row is not None:\n        alert_id, date, facility_id, sensor_id, level, detail = row\n        alert_notification = alerts_col.create_row()\n        timestamp = datetime_to_timestamp(date)\n        alert_notification.set_field_by_integer(0,alert_id)\n        alert_notification.set_field_by_timestamp(1,timestamp)\n        alert_notification.set_field_by_string(2,facility_id)\n        alert_notification.set_field_by_string(3,sensor_id)\n        alert_notification.set_field_integer(4,level)\n        alert_notification.set_field_by_string(5,detail)\n        ret = alerts_col.put_row(alert_notification)\n<\/pre>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>Now that all <b>4 PostgreSQL tables<\/b> are migrated, our migration to GridDB is complete. From there, all the benefits from the superior design and performance of GridDB can be obtained and all the PostgreSQL data can be dropped. With GridDB containers, we get the SQL qualities like <a href=\"https:\/\/griddb.net\/en\/blog\/griddb-complies-acid\/\">ACID compliance<\/a> but as well as NoSQL benefits like flexibility and high <a href=\"https:\/\/griddb.net\/en\/blog\/your-database-is-really-scalable\/\">scalability<\/a>. All it takes is good design and proper data modeling to make the transition from relational databases to GridDB seamless.<\/p>\n<h3 id=\"reference\">Reference<\/h3>\n<ul id=\"reference-points\" style=\"padding-left: 36px;\">\n<li>\n<p><a href=\"https:\/\/www.postgresql.org\/docs\/9.2\/static\/release-9-2-23.html\">PostgreSQL Version 9.2.23<\/a> was used as the PostgreSQL database.<\/p>\n<\/li>\n<li>\n<p><b>GridDB<\/b> <a href=\"https:\/\/github.com\/griddb\/griddb_nosql\/releases\/download\/v3.0.1\/griddb_nosql-3.0.1-1.linux.x86_64.rpm\" title=\"Download GridDB CE\">Community Edition 3.0.1<\/a> was used as a our GridDB database.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.python.org\/download\/releases\/2.7.3\/\" title=\"Download Python\">Python version 2.7.13<\/a> was used as the programming language to perform the migration on <b>CentOS 7.3<\/b> Linux Operating System.<\/p>\n<\/li>\n<li>\n<p>More information on using and accessing GridDB data with Python can be found on our <a href=\"https:\/\/griddb.net\/en\/blog\/using-griddbs-cpythonruby-apis\/\" title=\"Python API tutorial\">API post<\/a>.<\/p>\n<\/li>\n<li>\n<p>If you want to learn more about migrating relational data to GridDB, read our page that details migrating an <b>Oracle database<\/b> using the <a href=\"https:\/\/griddb.net\/en\/docs\/documents\/6-5_migration-from-other-databases.php\" title=\"Migrating with export\/import\">import and export functions<\/a> of GridDB Standard Edition.<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In one of our past posts, we migrated the relational database MySQL using Java. In this post we will continue a similar trend by showing step-by-step how to migrate an existing PostgreSQL database to a GridDB cluster with Python. Postgresql is a relational database that has been widely used in business intelligence, web development, [&hellip;]<\/p>\n","protected":false},"author":123,"featured_media":25798,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[121],"tags":[],"class_list":["post-46566","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Migrating from PostgreSQL to GridDB | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"Introduction In one of our past posts, we migrated the relational database MySQL using Java. In this post we will continue a similar trend by showing\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Migrating from PostgreSQL to GridDB | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"Introduction In one of our past posts, we migrated the relational database MySQL using Java. In this post we will continue a similar trend by showing\" \/>\n<meta property=\"og:url\" content=\"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/\" \/>\n<meta property=\"og:site_name\" content=\"GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/griddbcommunity\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-03-27T07:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-13T20:54:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.griddb.net\/wp-content\/uploads\/2018\/06\/blog_title_24.png\" \/>\n\t<meta property=\"og:image:width\" content=\"870\" \/>\n\t<meta property=\"og:image:height\" content=\"490\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Joshua Pascascio\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:site\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Joshua Pascascio\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/\"},\"author\":{\"name\":\"Joshua Pascascio\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/ca72185e9a3778df765a76313f789fd8\"},\"headline\":\"Migrating from PostgreSQL to GridDB\",\"datePublished\":\"2018-03-27T07:00:00+00:00\",\"dateModified\":\"2025-11-13T20:54:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/\"},\"wordCount\":307,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/griddb.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2018\/06\/blog_title_24.png\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/\",\"url\":\"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/\",\"name\":\"Migrating from PostgreSQL to GridDB | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2018\/06\/blog_title_24.png\",\"datePublished\":\"2018-03-27T07:00:00+00:00\",\"dateModified\":\"2025-11-13T20:54:33+00:00\",\"description\":\"Introduction In one of our past posts, we migrated the relational database MySQL using Java. In this post we will continue a similar trend by showing\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/#primaryimage\",\"url\":\"\/wp-content\/uploads\/2018\/06\/blog_title_24.png\",\"contentUrl\":\"\/wp-content\/uploads\/2018\/06\/blog_title_24.png\",\"width\":870,\"height\":490},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/griddb.net\/en\/#website\",\"url\":\"https:\/\/griddb.net\/en\/\",\"name\":\"GridDB: Open Source Time Series Database for IoT\",\"description\":\"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL\",\"publisher\":{\"@id\":\"https:\/\/griddb.net\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/griddb.net\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/griddb.net\/en\/#organization\",\"name\":\"Fixstars\",\"url\":\"https:\/\/griddb.net\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"contentUrl\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"width\":200,\"height\":83,\"caption\":\"Fixstars\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/griddbcommunity\/\",\"https:\/\/x.com\/GridDBCommunity\",\"https:\/\/www.linkedin.com\/company\/griddb-by-toshiba\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/ca72185e9a3778df765a76313f789fd8\",\"name\":\"Joshua Pascascio\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/872ef8be79cb5117c256feb4c279ac41b954bfba599d647db925185c449aff1c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/872ef8be79cb5117c256feb4c279ac41b954bfba599d647db925185c449aff1c?s=96&d=mm&r=g\",\"caption\":\"Joshua Pascascio\"},\"url\":\"https:\/\/www.griddb.net\/en\/author\/joshua\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Migrating from PostgreSQL to GridDB | GridDB: Open Source Time Series Database for IoT","description":"Introduction In one of our past posts, we migrated the relational database MySQL using Java. In this post we will continue a similar trend by showing","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:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/","og_locale":"en_US","og_type":"article","og_title":"Migrating from PostgreSQL to GridDB | GridDB: Open Source Time Series Database for IoT","og_description":"Introduction In one of our past posts, we migrated the relational database MySQL using Java. In this post we will continue a similar trend by showing","og_url":"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/","og_site_name":"GridDB: Open Source Time Series Database for IoT","article_publisher":"https:\/\/www.facebook.com\/griddbcommunity\/","article_published_time":"2018-03-27T07:00:00+00:00","article_modified_time":"2025-11-13T20:54:33+00:00","og_image":[{"width":870,"height":490,"url":"https:\/\/www.griddb.net\/wp-content\/uploads\/2018\/06\/blog_title_24.png","type":"image\/png"}],"author":"Joshua Pascascio","twitter_card":"summary_large_image","twitter_creator":"@GridDBCommunity","twitter_site":"@GridDBCommunity","twitter_misc":{"Written by":"Joshua Pascascio","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/#article","isPartOf":{"@id":"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/"},"author":{"name":"Joshua Pascascio","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/ca72185e9a3778df765a76313f789fd8"},"headline":"Migrating from PostgreSQL to GridDB","datePublished":"2018-03-27T07:00:00+00:00","dateModified":"2025-11-13T20:54:33+00:00","mainEntityOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/"},"wordCount":307,"commentCount":0,"publisher":{"@id":"https:\/\/griddb.net\/en\/#organization"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2018\/06\/blog_title_24.png","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/","url":"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/","name":"Migrating from PostgreSQL to GridDB | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/griddb.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/#primaryimage"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2018\/06\/blog_title_24.png","datePublished":"2018-03-27T07:00:00+00:00","dateModified":"2025-11-13T20:54:33+00:00","description":"Introduction In one of our past posts, we migrated the relational database MySQL using Java. In this post we will continue a similar trend by showing","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/blog\/migrating-from-postgresql-to-griddb\/#primaryimage","url":"\/wp-content\/uploads\/2018\/06\/blog_title_24.png","contentUrl":"\/wp-content\/uploads\/2018\/06\/blog_title_24.png","width":870,"height":490},{"@type":"WebSite","@id":"https:\/\/griddb.net\/en\/#website","url":"https:\/\/griddb.net\/en\/","name":"GridDB: Open Source Time Series Database for IoT","description":"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL","publisher":{"@id":"https:\/\/griddb.net\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/griddb.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/griddb.net\/en\/#organization","name":"Fixstars","url":"https:\/\/griddb.net\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/","url":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","contentUrl":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","width":200,"height":83,"caption":"Fixstars"},"image":{"@id":"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/griddbcommunity\/","https:\/\/x.com\/GridDBCommunity","https:\/\/www.linkedin.com\/company\/griddb-by-toshiba"]},{"@type":"Person","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/ca72185e9a3778df765a76313f789fd8","name":"Joshua Pascascio","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/872ef8be79cb5117c256feb4c279ac41b954bfba599d647db925185c449aff1c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/872ef8be79cb5117c256feb4c279ac41b954bfba599d647db925185c449aff1c?s=96&d=mm&r=g","caption":"Joshua Pascascio"},"url":"https:\/\/www.griddb.net\/en\/author\/joshua\/"}]}},"_links":{"self":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/46566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/users\/123"}],"replies":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/comments?post=46566"}],"version-history":[{"count":1,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/46566\/revisions"}],"predecessor-version":[{"id":51257,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/46566\/revisions\/51257"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/media\/25798"}],"wp:attachment":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/media?parent=46566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/categories?post=46566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/tags?post=46566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}