Returning SELECTed rows immediately instead of all at the end?

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Returning SELECTed rows immediately instead of all at the end?
Date: 2020-06-13 04:39:58
Message-ID: d9254330-2f4d-f851-a815-3df56e95c59a@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I'm running amcheck on a set of indices (test machine, not prod) and want to
track the progress.  Is there a SELECT clause that makes rows display as
they are created, or do I have to explicitly call bt_index_check() from a
shell script or SQL function in order to see the output as each index is
checked?

postgres=# select version();
                    version
------------------------------------------------------
PostgreSQL 9.6.18 on [snip] (Red Hat 4.4.7-23), 64-bit
(1 row)

postgres=# \dx
                           List of installed extensions
     Name     | Version |   Schema   | Description
--------------+---------+------------+--------------------------------------------
amcheck_next | 2       | public     | functions for verifying relation integrity
plpgsql      | 1.0     | pg_catalog | PL/pgSQL procedural language

#!/bin/bash
echo `date +"%F %T, %a"` Starting
psql CDSLBXW -c \
"SELECT clock_timestamp(),
        bt_index_check(c.oid, i.indisunique),
        n.nspname,
        c.relname ,
        c.relpages
FROM pg_index i
       JOIN pg_opclass op ON i.indclass[0] = op.oid
       JOIN pg_am am ON op.opcmethod = am.oid
       JOIN pg_class c ON i.indexrelid = c.oid
       JOIN pg_namespace n ON c.relnamespace = n.oid
WHERE am.amname = 'btree'
  AND c.relpersistence != 't'
  AND c.relkind = 'i'
  AND i.indisready
  AND i.indisvalid
ORDER BY c.relpages desc
;"

echo `date +"%F %T, %a"` Finished

--
Angular momentum makes the world go 'round.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2020-06-13 05:04:42 Re: Returning SELECTed rows immediately instead of all at the end?
Previous Message Peter 2020-06-13 03:24:53 Re: Something else about Redo Logs disappearing