Improve pg_dump's query for retrieving BLOB comments to be more efficient
authorTom Lane
Wed, 1 Apr 2009 18:54:27 +0000 (18:54 +0000)
committerTom Lane
Wed, 1 Apr 2009 18:54:27 +0000 (18:54 +0000)
when there are many blobs and not so many comments.  Tamas Vincze

src/bin/pg_dump/pg_dump.c

index dc652aad74725136a72dc9f277dcd50b535ef9d1..7d46d80e91fb484d812668a4540570bda7357f88 100644 (file)
@@ -12,7 +12,7 @@
  * by PostgreSQL
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.531 2009/03/26 22:26:07 petere Exp $
+ *   $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.532 2009/04/01 18:54:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1995,7 +1995,13 @@ dumpBlobComments(Archive *AH, void *arg)
    selectSourceSchema("pg_catalog");
 
    /* Cursor to get all BLOB comments */
-   if (AH->remoteVersion >= 70200)
+   if (AH->remoteVersion >= 70300)
+       blobQry = "DECLARE blobcmt CURSOR FOR SELECT loid, "
+                 "obj_description(loid, 'pg_largeobject') "
+                 "FROM (SELECT DISTINCT loid FROM "
+                 "pg_description d JOIN pg_largeobject l ON (objoid = loid) "
+                 "WHERE classoid = 'pg_largeobject'::regclass) ss";
+   else if (AH->remoteVersion >= 70200)
        blobQry = "DECLARE blobcmt CURSOR FOR SELECT loid, "
                  "obj_description(loid, 'pg_largeobject') "
                  "FROM (SELECT DISTINCT loid FROM pg_largeobject) ss";