Page 1 of 1

[Solved] Strange metadata queries

Posted: 26.02.2014, 19:48
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

Re: Strange metadata queries

Posted: 27.02.2014, 15:20
by martinrame
I've also found, by enabling logging on the server, that those queries are sent even without TZSqlmonitor enabled.

Re: Strange metadata queries

Posted: 28.02.2014, 10:01
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

Re: [Solved] Strange metadata queries

Posted: 28.02.2014, 15:32
by martinrame
Thanks marsupilami, I was already using TZQuery.ReadOnly := True. After setting UseMetadata in TZConnection the messages where removed.