diff --git a/plugins/views_data_export_plugin_display_export.inc b/plugins/views_data_export_plugin_display_export.inc
index b9077c0..e5cac88 100644
--- a/plugins/views_data_export_plugin_display_export.inc
+++ b/plugins/views_data_export_plugin_display_export.inc
@@ -720,7 +720,6 @@ class views_data_export_plugin_display_export extends views_plugin_display_feed
    */
   function is_compatible() {
     $incompatible_drivers = array (
-      'pgsql',
     );
     $db_driver = $this->_get_database_driver();
     return !in_array($db_driver, $incompatible_drivers);
@@ -820,9 +819,23 @@ class views_data_export_plugin_query_default_batched extends views_plugin_query_
         // TODO: this could probably be replaced with a query extender and new query type.
         $query->preExecute();
         $args = $query->getArguments();
-        $insert_query = 'CREATE TABLE {' . $display_handler->index_tablename() . '} SELECT @row := @row + 1 AS ' . $display_handler->batched_execution_state->sandbox['weight_field_alias'] . ', ' . implode(', ', $select_aliases) . ' FROM (' . (string)$query . ') AS cl, (SELECT @row := 0) AS r';
-        db_query($insert_query, $args);
 
+        $db_type = Database::getConnection()->databaseType();
+        switch ($db_type) {
+          case "pgsql":
+            // Create temporary sequence
+            $seq_name = $display_handler->index_tablename();
+            $create_seq_query = 'CREATE TEMP sequence ' . $seq_name;
+            // query uses sequence to create row number
+            $insert_query = 'CREATE TABLE {' . $display_handler->index_tablename() . "} AS SELECT nextval('".$seq_name."') AS " . $display_handler->batched_execution_state->sandbox['weight_field_alias'] . ', ' . implode(', ', $select_aliases) . ' FROM (' . (string)$query . ') AS cl';
+            db_query($create_seq_query);
+            break;
+          default:
+            $insert_query = 'CREATE TABLE {' . $display_handler->index_tablename() . '} SELECT @row := @row + 1 AS ' . $display_handler->batched_execution_state->sandbox['weight_field_alias'] . ', ' . implode(', ', $select_aliases) . ' FROM (' . (string)$query . ') AS cl, (SELECT @row := 0) AS r';
+            break;
+        }
+
+        db_query($insert_query, $args);
 
         $view->result = array();
 
diff --git a/views_data_export.module b/views_data_export.module
index d4088d7..7942149 100644
--- a/views_data_export.module
+++ b/views_data_export.module
@@ -246,7 +246,12 @@ function views_data_export_view_store($export_id, $view) {
  */
 function views_data_export_view_retrieve($export_id) {
   views_include('view');
-  $data = db_query("SELECT * FROM {views_data_export_object_cache} WHERE eid = :eid", array(':eid' => $export_id))->fetch();
+  $data = db_select('views_data_export_object_cache', 'v')
+    ->fields('v')
+    ->condition('eid', $export_id, '=')
+    ->execute()
+    ->fetch();
+  $view = unserialize($data);
   if ($data) {
     $view = unserialize($data->data);
   }
