Optimize CDB_ColumnNames

This implementation is about 1000 times faster
This commit is contained in:
Javier Goizueta 2016-04-18 18:49:58 +02:00
parent 6908fb4672
commit bd5ae84e90

View File

@ -2,15 +2,13 @@
CREATE OR REPLACE FUNCTION CDB_ColumnNames(REGCLASS) CREATE OR REPLACE FUNCTION CDB_ColumnNames(REGCLASS)
RETURNS SETOF information_schema.sql_identifier RETURNS SETOF information_schema.sql_identifier
AS $$ AS $$
SELECT
SELECT c.column_name a.attname::information_schema.sql_identifier column_name
FROM information_schema.columns c, pg_class _tn, pg_namespace _sn FROM pg_class c
WHERE table_name = _tn.relname LEFT JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
AND table_schema = _sn.nspname WHERE c.oid = $1::oid
AND _tn.oid = $1::oid AND a.attstattarget = -1
AND _sn.oid = _tn.relnamespace ORDER BY a.attnum;
ORDER BY ordinal_position;
$$ LANGUAGE SQL; $$ LANGUAGE SQL;
-- This is to migrate from pre-0.2.0 version -- This is to migrate from pre-0.2.0 version