Netezza find distribution key of a table programatically

Richard Knop picture Richard Knop · Jul 29, 2014 · Viewed 7.4k times · Source

Is it possible to programatically find what sort of distribution algorithm a Netezza table is using?

I can do it manually in Workbench by exporting table DDL but I would like to be able to do it programatically by running some sort of metadata SQL query.

I looked into most system tables but can't find this information anywhere.

Any ideas?

Answer

Richard Knop picture Richard Knop · Jul 29, 2014

There might be a solution to this.

Running this query:

select * from _v_table_dist_map where database='database' and tablename='tablename';

If it returns no rows, it can be assumed a random distribution is being used (DISTRIBUTE ON RANDOM).

If it returns 1 or more rows, column based destribution is being used (DISTRIBUTE ON (col1, ..., coln)).