diff -ur SemanticMediaWiki/includes/storage/SMW_SQLHelpers.php /var/www/mw/extensions/SemanticMediaWiki/includes/storage/SMW_SQLHelpers.php
--- SemanticMediaWiki/includes/storage/SMW_SQLHelpers.php	2012-12-02 09:53:38.000000000 +0100
+++ /var/www/mw/extensions/SemanticMediaWiki/includes/storage/SMW_SQLHelpers.php	2012-12-03 21:16:39.984593006 +0100
@@ -373,7 +373,7 @@
 				$type = 'INDEX';
 			}
 
-			self::createIndex( $db, $type, "{$tableName}_index{$key}", $tableName, $columns, $reportTo );
+			self::createIndex( $db, $type, "{$rawTableName}_index{$key}", $tableName, $columns, $reportTo );
 		}
 
 		self::reportProgress( "   ... done.\n", $reportTo );
@@ -492,7 +492,7 @@
 		self::reportProgress( "   ... creating new index $columns ...", $reportTo );
 		if ( $wgDBtype == 'postgres' ) { // postgresql
 			if ( $db->indexInfo( $tableName, $indexName ) === false ) {
-				$db->query( "CREATE $type $tableName ON $tableName USING btree($columns)", __METHOD__ );
+				$db->query( "CREATE $type $indexName ON $tableName USING btree($columns)", __METHOD__ );
 			}
 		} elseif ( $wgDBtype == 'sqlite' ) { // SQLite
 			$db->query( "CREATE $type $indexName ON $tableName ($columns)", __METHOD__ );
@@ -513,4 +513,4 @@
 		if ( !is_null( $receiver ) ) $receiver->reportProgress( $msg );
 	}
 
-}
\ No newline at end of file
+}
diff -ur SemanticMediaWiki/includes/storage/SQLStore/SMW_SQLStore3_SetupHandlers.php /var/www/mw/extensions/SemanticMediaWiki/includes/storage/SQLStore/SMW_SQLStore3_SetupHandlers.php
--- SemanticMediaWiki/includes/storage/SQLStore/SMW_SQLStore3_SetupHandlers.php	2012-12-02 09:53:38.000000000 +0100
+++ /var/www/mw/extensions/SemanticMediaWiki/includes/storage/SQLStore/SMW_SQLStore3_SetupHandlers.php	2012-12-03 21:34:56.227098824 +0100
@@ -124,7 +124,7 @@
 			$reportTo
 		);
 
-		SMWSQLHelpers::setupIndex( SMWSQLStore3::PROPERTY_STATISTICS_TABLE, array( array( 'p_id', 'UNIQUE' ), 'usage_count' ), $db );
+		SMWSQLHelpers::setupIndex( SMWSQLStore3::PROPERTY_STATISTICS_TABLE, array( array( 'p_id', 'UNIQUE INDEX' ), 'usage_count' ), $db );
 
 		// Set up all property tables as defined:
 		$this->setupPropertyTables( $dbtypes, $db, $reportTo );
@@ -261,7 +261,8 @@
 			$max = $db->selectField( SMWSql3SmwIds::tableName, 'max(smw_id)', array(), __METHOD__ );
 			$max += 1;
 
-			$db->query( "ALTER SEQUENCE smw_ids_smw_id_seq RESTART WITH {$max}", __METHOD__ );
+			$t = SMWSql3SmwIds::tableName;
+			$db->query( "ALTER SEQUENCE {$t}_smw_id_seq RESTART WITH {$max}", __METHOD__ );
 		}
 
 		$this->reportProgress( "Internal properties initialised successfully.\n", $verbose );
@@ -311,7 +312,7 @@
 
 			$dbw->replace(
 				SMWSQLStore3::PROPERTY_STATISTICS_TABLE,
-				'p_id',
+				array('p_id'),
 				array(
 					'p_id' => $row->smw_id,
 					'usage_count' => $usageCount
