psql mydb psql (11.11) Type "help" for help.
Toggle timing on/off like this:
mydb=# \timing Timing is on. mydb=# \timing Timing is off.
Minimalistic Oracle contains a collection of practical examples from my encounters with Oracle technologies. When relevant, I also write about other technologies, like Linux or PostgreSQL. Many of the posts starts with "how to" since they derive directly from my own personal experience. My goal is to provide simple examples, so that they can be easily adapted to other situations.
psql mydb psql (11.11) Type "help" for help.
mydb=# \timing Timing is on. mydb=# \timing Timing is off.
ORA-14024: number of partitions of LOCAL index must equal that of the underlying table ORA-06512: at "SYS.DBMS_REDEFINITION", line 2761This was because I was using the directive dbms_redefinition.cons_orig_params in my code:
BEGIN
DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS(uname=>'SALES',
orig_table=>'DAILYSALES',
int_table=>'DAILYSALES_INTERIM',
copy_indexes=>dbms_redefinition.cons_orig_params,
copy_triggers=>TRUE,
copy_constraints=>TRUE,
copy_privileges=>TRUE,
ignore_errors=>FALSE,
num_errors => l_num_errors,
copy_statistics=>TRUE,
copy_mvlog=>TRUE);
END;
/
As such, the redefinition process attempted to transfer the partitioned index from the original table which had a different partitioning scheme, to the new table who was partitioned differently and had fewer partitions.
CREATE INDEX SALES.SEARCHIX1_INTERIM ON SALES.DAILYSALES_INTERIM (COL1, COL2 DESC) TABLESPACE DATA2 LOCAL PARALLEL ( DEGREE 5 INSTANCES 1 );Then, "plug it into" the redefinition procedure:
exec DBMS_REDEFINITION.REGISTER_DEPENDENT_OBJECT('SALES','DAILYSALES','DAILYSALES_INTERIM',2,'SALES','SEARCHIX1','SEARCHIX1_INTERIM');Finally, change the directive in your COPY_TABLE_DEPENDENTS procedure from
copy_indexes=>dbms_redefinition.cons_orig_paramsto
copy_indexes=>0And run the COPY_TABLE_DEPENDENTS procedure again.
select context from pg_settings where name = 'enable_parallel_hash';Result:
context --------- user (1 row)"user" means that the parameter can be set in a user's session. Thanks to Daniel Westerman for writing the useful article where I found this useful information.
SET max_parallel_workers_per_gather=num;
su - postgresCreate a file called find_hp.sh. Insert the following:
#!/bin/bash pid=`head -1 $PGDATA/postmaster.pid` echo "Pid: $pid" peak=`grep ^VmPeak /proc/$pid/status | awk '{ print $2 }'` echo "VmPeak: $peak kB" hps=`grep ^Hugepagesize /proc/meminfo | awk '{ print $2 }'` echo "Hugepagesize: $hps kB" hp=$((peak/hps)) echo Set Huge Pages: $hpMake sure the environment variable $PGDATA is set. Give the script execution rights:
chmod 755 find_hp.shExecute it, and it will tell you how many huge pages you need:
./find_hp.sh Pid: 128678 VmPeak: 68986484 kB Hugepagesize: 2048 kB Set Huge Pages: 33684I can now proceed to allow for 33684 huge pages on my system with
sysctl -w vm.nr_hugepages=33684
for a in `echo "\t \dt+ myschema.*" | psql proddb01 | awk -F '[|]' '{ print $2 }'`; do echo "SELECT relname, reltuples::BIGINT AS estimate FROM pg_class WHERE relname='$a';" | psql proddb01 done
chmod 755 find_rows.sh ./find_rows.shExample output:
relname | estimate ----------------------------+---------- table1 | 0 (1 row) relname | estimate ------------------------------+---------- table2 | 65525596 (1 row) relname | estimate -----------------------+----------- table3 | 153588080 (1 row) relname | estimate --------------------+---------- table4 | 1 (1 row)
proddb01=# \dn List of schemas Name | Owner --------------------------+---------- sales | postgres hr | postgres manufacturing | postgres public | postgres (4 rows)Turn off unneccessary output like this:
proddb01=# \t Tuples only is on.Try again:
proddb01=# \dn sales | postgres hr | postgres manufacturing | postgres public | postgres