Skip to content

Optimize index bloat output #93

Description

@MichaelDBA

Very cool SQL tool! Thanks!!!!!

Using b2 option, we get a lot of unnecessary bloat output for very small indexes:

      | pg_sequence_seqrelid_index                   +| 16 kB  | ~0 bytes (0.00%)     | ~0 bytes (0.00%)     | ~16 kB  |         90
        |   (pg_catalog.pg_sequence)                    |        |                      |                      |         |
        | pg_shdescription_o_c_index                   +| 16 kB  | ~0 bytes (0.00%)     | ~0 bytes (0.00%)     | ~16 kB  |         90
        |   (pg_catalog.pg_shdescription)               |        |                      |                      |         |
        | pg_tablespace_oid_index                      +| 16 kB  | ~0 bytes (0.00%)     | ~0 bytes (0.00%)     | ~16 kB  |         90
        |   (pg_catalog.pg_tablespace)                  |        |                      |                      |         |
        | pg_tablespace_spcname_index                  +| 16 kB  | ~0 bytes (0.00%)     | ~0 bytes (0.00%)     | ~16 kB  |         90
        |   (pg_catalog.pg_tablespace)                  |        |                      |                      |         |
        | pg_trigger_oid_index                         +| 16 kB  | ~0 bytes (0.00%)     | ~0 bytes (0.00%)     | ~16 kB  |         90
        |   (pg_catalog.pg_trigger)                     |        |                      |                      |         |
        | pg_trigger_tgconstraint_index                +| 16 kB  | ~0 bytes (0.00%)     | ~0 bytes (0.00%)     | ~16 kB  |         90
        |   (pg_catalog.pg_trigger)                     |        |                      |                      |         |

Can you optimize the where clause so that very small or not used or not populated indexes are not shown in the output?

Also for b4 output, same kinda thing:

              Table               |                   Index                   | Table size | Index size | Index Scans | Wasted, % |   Wasted
----------------------------------+-------------------------------------------+------------+------------+-------------+-----------+------------
 sample_c1.stock_0                | sample_c1.stock_0_warehouse_id_idx        | 8192 bytes | 16 kB      |           0 |      99.0 | 16 kB
 sample_c2.activity               | sample_c2.activity_pid_idx                | 8192 bytes | 16 kB      |           0 |      99.0 | 16 kB
 sample.items_2                   | sample.items_2_pkey                       | 8192 bytes | 16 kB      |           1 |      99.0 | 16 kB
 sample_c1.stock_0                | sample_c1.stock_0_item_id_idx             | 8192 bytes | 16 kB      |           0 |      99.0 | 16 kB
 sample_c1.items_2                | sample_c1.items_2_pkey                    | 8192 bytes | 16 kB      |           0 |      99.0 | 16 kB
 sample.warehouses                | sample.warehouses_pkey                    | 8192 bytes | 16 kB      |           1 |      99.0 | 16 kB
 sample.stock_0                   | sample.stock_0_item_id_idx                | 8192 bytes | 16 kB      |           0 |      99.0 | 16 kB
 sample_c2.stock_0                | sample_c2.stock_0_warehouse_id_idx        | 8192 bytes | 16 kB      |           0 |      99.0 | 16 kB
 sample.stock_0                   | sample.stock_0_warehouse_id_idx           | 8192 bytes | 16 kB      |           0 |      99.0 | 16 kB

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions