Dear Phil
In IBM i, there are multiple ways available for index maintenance method. The default (and most prevalent) one is "Immediate (on-line) Maintenance" and what Birgitta describes is based on this method.
In IBM i release 7.x, a product name DB2 SMP (Symmetric Multiproceesing) is now free of charge (but need an active SWMA). Index build process can utilize DB2 SMP for faster build time when the index is large.
If you use SQL CREATE INDEX, precede it with SET CURRENT DEGREE = 'N' where N is an integer value. My personal rule of thumb is to use N = 3 for each active POWER9 or 10 core that is available in the LPAR.
------------------------------
Chance favors only the prepared mind.
-- Louis Pasteur
------------------------------
Satid S.
------------------------------
Original Message:
Sent: Thu September 28, 2023 03:00 PM
From: Phil Meador
Subject: Truncate/Load table with Index
We do a lot of Truncate and loading of tables in our ETL. Currently, we don't use indexes on almost anything. I am looking to change that, but I want to understand how this might work. Say I have a table that is created, loaded, and indexed. I now truncate the table and start inserting records.
- what happens to my index when I truncate? Does it essentially become "empty"? Is it still valid?
- When I start inserting records, does it just rebuild?
- Are there any performance issues with having existing indexes and reloading millions of records? Let's assume I have a lot of indexes.
- It had been suggested to me that the indexes should be dropped and rebuild after. Is that really necessary? I could see some complications with that given primary/unique keys. DB2 seems too friendly to require this of me!!
I am sure there is a best practice here. I appreciate any advice. Thanks
------------------------------
Phil Meador
------------------------------
#SQL