[Solved] Strange metadata queries

Forum related to PostgreSQL

Moderators: gto, cipto_kh, EgonHugeist, olehs

Post Reply
martinrame
Junior Boarder
Junior Boarder
Posts: 25
Joined: 24.10.2006, 18:29
Location: Córdoba, Argentina
Contact:

[Solved] Strange metadata queries

Post by martinrame »

Hi, I've added a TZSqlMonitor (which is awesome) to my program, for optimization purpouses, and found there are many metadata queries made by Zeos, between my own queries. Is there a way to turn off those?.

Those queries are similar to this:

Code: Select all

SELECT n.nspname,c.relname,a.attname,a.atttypid,a.attnotnull,a.atttypmod,a.attlen,a.attnum,pg_get_expr(def.adbin, def.adrelid) as adsrc,dsc.description  FROM pg_catalog.pg_namespace n  JOIN pg_catalog.pg_class c ON (c.relnamespace = n.oid)  JOIN pg_catalog.pg_attribute a ON (a.attrelid=c.oid)  LEFT JOIN pg_catalog.pg_attrdef def ON (a.attrelid=def.adrelid AND a.attnum = def.adnum) LEFT JOIN pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum = dsc.objsubid)  LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid AND dc.relname='pg_class') LEFT JOIN pg_catalog.pg_namespace dn ON (dc.relnamespace=dn.oid AND dn.nspname='pg_catalog')  WHERE a.attnum > 0 AND NOT a.attisdropped AND c.relname LIKE E'sysconfig' AND a.attname LIKE E'%' ORDER BY nspname,relname,attnum
Last edited by martinrame on 28.02.2014, 15:31, edited 1 time in total.
martinrame
Junior Boarder
Junior Boarder
Posts: 25
Joined: 24.10.2006, 18:29
Location: Córdoba, Argentina
Contact:

Re: Strange metadata queries

Post by martinrame »

I've also found, by enabling logging on the server, that those queries are sent even without TZSqlmonitor enabled.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1935
Joined: 17.01.2011, 14:17

Re: Strange metadata queries

Post by marsupilami »

Hello Leonardo,

these queries are usually used to get information about meta data of the database objects. The query you mention is usually used to get the fields of a table. You can try different things to reduce this kind of queries like not using TZTable, and using TZReadOnlyQuery or TZQuery with ReadOnly = True where possible.
Also you could set TZConnection.UseMetadata to false. This should suppress most of the queries but also would render all your queries ReadOnly unless you provide suitable TZUpdateSQL components. For more information on TZConnection.UseMetadata see this thread: http://zeoslib.sourceforge.net/viewtopic.php?f=33&t=3590
Best regards,

Jan
martinrame
Junior Boarder
Junior Boarder
Posts: 25
Joined: 24.10.2006, 18:29
Location: Córdoba, Argentina
Contact:

Re: [Solved] Strange metadata queries

Post by martinrame »

Thanks marsupilami, I was already using TZQuery.ReadOnly := True. After setting UseMetadata in TZConnection the messages where removed.
Post Reply