Thread: Performance of pgAdmin 14 Beta 1

Performance of pgAdmin 14 Beta 1

From
Kieran McCusker
Date:
Hi

I've noticed the performance of version 14 is noticeably worse than 
version 12 when clicking on tables.

~0.1 seconds for V12 comapared to ~0.5 seconds in V14.

Looking at the logs I see that the details for all the tabs are selected 
by V14 but in V12 only the details for the current tab of the property 
pane are selected.

As the additional tabs are used much less frequently by me and my users 
couldn't they be lazy loaded as they were in V12?

Many thanks

Kieran

For reference the slow queries are the 4th, 5th and 6th in the log:-


SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,       CASE WHEN cl.relkind IS NOT NULL THEN
cl.relkind|| 
 
COALESCE(dep.objsubid::text, '')            WHEN tg.oid IS NOT NULL THEN 'T'::text            WHEN ty.oid IS NOT NULL
THEN'y'::text            WHEN ns.oid IS NOT NULL THEN 'n'::text            WHEN pr.oid IS NOT NULL THEN 'p'::text
    WHEN la.oid IS NOT NULL THEN 'l'::text            WHEN rw.oid IS NOT NULL THEN 'R'::text            WHEN co.oid IS
NOTNULL THEN 'C'::text || contype            WHEN ad.oid IS NOT NULL THEN 'A'::text            ELSE '' END AS type,
 COALESCE(coc.relname, clrw.relname) AS ownertable,       CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL

THEN cl.relname || '.' || att.attname            ELSE COALESCE(cl.relname, co.conname, pr.proname, 
tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname)       END AS refname,       COALESCE(nsc.nspname,
nso.nspname,nsp.nspname, nst.nspname, 
 
nsrw.nspname) AS nspname  FROM pg_depend dep  LEFT JOIN pg_class cl ON dep.objid=cl.oid  LEFT JOIN pg_attribute att ON
dep.objid=att.attrelidAND 
 
dep.objsubid=att.attnum  LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid  LEFT JOIN pg_proc pr ON
dep.objid=pr.oid LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid  LEFT JOIN pg_trigger tg ON dep.objid=tg.oid
LEFTJOIN pg_type ty ON dep.objid=ty.oid  LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid  LEFT JOIN pg_constraint
coON dep.objid=co.oid  LEFT JOIN pg_class coc ON co.conrelid=coc.oid  LEFT JOIN pg_namespace nso ON
co.connamespace=nso.oid LEFT JOIN pg_rewrite rw ON dep.objid=rw.oid  LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class
LEFTJOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid  LEFT JOIN pg_language la ON dep.objid=la.oid  LEFT JOIN
pg_namespacens ON dep.objid=ns.oid  LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid WHERE dep.refobjid=26997594::oid   AND
classidIN (   SELECT oid FROM pg_class    WHERE relname IN ('pg_class', 'pg_constraint', 'pg_conversion', 
 
'pg_language', 'pg_proc',                      'pg_rewrite', 'pg_namespace', 'pg_trigger', 
'pg_type', 'pg_attrdef')) ORDER BY classid, cl.relkind;

SELECT ref.relname AS refname, d2.refclassid, dep.deptype AS deptype  FROM pg_depend dep  LEFT JOIN pg_depend d2 ON
dep.objid=d2.objidAND dep.refobjid != 
 
d2.refobjid  LEFT JOIN pg_class ref ON ref.oid=d2.refobjid  LEFT JOIN pg_attribute att ON d2.refclassid=att.attrelid
AND
 
d2.refobjsubid=att.attnum WHERE dep.refobjid=26997594::oid    AND dep.classid=(SELECT oid FROM 
pg_class WHERE relname='pg_attrdef')    AND dep.refobjid NOT IN (SELECT d3.refobjid FROM pg_depend d3 WHERE 
d3.objid=d2.refobjid);


SELECT att.*, def.*, pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS 
defval, CASE WHEN att.attndims > 0 THEN 1 ELSE 0 END AS isarray, 
format_type(ty.oid,NULL) AS typname, format_type(ty.oid,att.atttypmod) 
AS displaytypname, tn.nspname as typnspname, et.typname as elemtypname,  ty.typstorage AS defaultstorage, cl.relname,
na.nspname,
 
att.attstattarget, description, cs.relname AS sername, ns.nspname AS 
serschema,  (SELECT count(1) FROM pg_type t2 WHERE t2.typname=ty.typname) > 1 AS 
isdup, indkey,  CASE       WHEN inh.inhparent IS NOT NULL AND att.attinhcount>0            THEN inh.inhparent::regclass
     ELSE NULL  END AS inhrelname,  EXISTS(SELECT 1 FROM  pg_constraint WHERE conrelid=att.attrelid AND 
 
contype='f' AND att.attnum=ANY(conkey)) As isfk  FROM pg_attribute att  JOIN pg_type ty ON ty.oid=atttypid  JOIN
pg_namespacetn ON tn.oid=ty.typnamespace  JOIN pg_class cl ON cl.oid=att.attrelid  JOIN pg_namespace na ON
na.oid=cl.relnamespace LEFT OUTER JOIN pg_inherits inh ON inh.inhrelid=att.attrelid  LEFT OUTER JOIN pg_type et ON
et.oid=ty.typelem LEFT OUTER JOIN pg_attrdef def ON adrelid=att.attrelid AND 
 
adnum=att.attnum  LEFT OUTER JOIN pg_description des ON des.objoid=att.attrelid AND 
des.objsubid=att.attnum  LEFT OUTER JOIN (pg_depend JOIN pg_class cs ON objid=cs.oid AND 
cs.relkind='S') ON refobjid=att.attrelid AND refobjsubid=att.attnum  LEFT OUTER JOIN pg_namespace ns ON
ns.oid=cs.relnamespace LEFT OUTER JOIN pg_index pi ON pi.indrelid=att.attrelid AND indisprimary WHERE att.attrelid =
26997594::oid  AND att.attnum > 0   AND att.attisdropped IS FALSE ORDER BY att.attnum;
 

SELECT DISTINCT ON(cls.relname) cls.oid, cls.relname as idxname, 
indrelid, indkey, indisclustered, indisunique, indisprimary, n.nspname,       indnatts, cls.reltablespace AS spcoid,
spcname,tab.relname as 
 
tabname, indclass, con.oid AS conoid, CASE contype WHEN 'p' THEN 
desp.description WHEN 'u' THEN desp.description WHEN 'x' THEN 
desp.description ELSE des.description END AS description,       pg_get_expr(indpred, indrelid, true) as indconstraint,
contype,
 
condeferrable, condeferred, amname
, substring(array_to_string(cls.reloptions, ',') from 
'fillfactor=([0-9]*)') AS fillfactor  FROM pg_index idx  JOIN pg_class cls ON cls.oid=indexrelid  JOIN pg_class tab ON
tab.oid=indrelid LEFT OUTER JOIN pg_tablespace ta on ta.oid=cls.reltablespace  JOIN pg_namespace n ON
n.oid=tab.relnamespace JOIN pg_am am ON am.oid=cls.relam  LEFT JOIN pg_depend dep ON (dep.classid = cls.tableoid AND
dep.objid
 
= cls.oid AND dep.refobjsubid = '0' AND dep.refclassid=(SELECT oid FROM 
pg_class WHERE relname='pg_constraint') AND dep.deptype='i')  LEFT OUTER JOIN pg_constraint con ON (con.tableoid =
dep.refclassid
 
AND con.oid = dep.refobjid)  LEFT OUTER JOIN pg_description des ON des.objoid=cls.oid  LEFT OUTER JOIN pg_description
despON (desp.objoid=con.oid AND 
 
desp.objsubid = 0) WHERE indrelid = 26997594::oid   AND contype='p'
 ORDER BY cls.relname;




Re: Performance of pgAdmin 14 Beta 1

From
Guillaume Lelarge
Date:
On 05/17/2011 01:00 PM, Kieran McCusker wrote:
> [...]
> I've noticed the performance of version 14 is noticeably worse than
> version 12 when clicking on tables.
> 
> ~0.1 seconds for V12 comapared to ~0.5 seconds in V14.
> 
> Looking at the logs I see that the details for all the tabs are selected
> by V14 but in V12 only the details for the current tab of the property
> pane are selected.
> 
> As the additional tabs are used much less frequently by me and my users
> couldn't they be lazy loaded as they were in V12?
> 

This behaviour change was done when we added the feature that allows one
to move the tabs
(http://git.postgresql.org/gitweb?p=pgadmin3.git;a=commitdiff;h=5a02585b3bfa7c7d1f643c30daa1ad3136e66e3d).
It does more than that, and it gives us much more features we wish to
use in future releases.


-- 
Guillaumehttp://www.postgresql.frhttp://dalibo.com


Re: Performance of pgAdmin 14 Beta 1

From
Kieran McCusker
Date:
Hi

Thanks for the response. I take your point, but for ourselves where we
have ~6000 tables and almost 700 schemas speed is important. Our staff
have never looked (and never needed to) at the information in the
Statistics, Dependencies and Dependents tabs so the loss in performance
is not balanced by additional functionality for them, however I
understand the difficulties in balancing the different requirements of
disparate user groups using a product.

If we cannot go back to lazy loading these tabs would it be possible to
disable or hide these tabs and the corresponding querys in File ->
Options (similar to the browser tab or maybe a general "simple mode"
type idea).

Many Thanks

Kieran


Re: Performance of pgAdmin 14 Beta 1

From
Dave Page
Date:
On Thu, Jun 2, 2011 at 9:46 AM, Kieran McCusker
<kieran.mccusker@kwest.info> wrote:
> If we cannot go back to lazy loading these tabs would it be possible to
> disable or hide these tabs and the corresponding querys in File ->
> Options (similar to the browser tab or maybe a general "simple mode"
> type idea).

I'll look into it.


-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: Performance of pgAdmin 14 Beta 1

From
Dave Page
Date:
On Thu, Jun 2, 2011 at 11:29 AM, Dave Page <dpage@pgadmin.org> wrote:
> On Thu, Jun 2, 2011 at 9:46 AM, Kieran McCusker
> <kieran.mccusker@kwest.info> wrote:
>> If we cannot go back to lazy loading these tabs would it be possible to
>> disable or hide these tabs and the corresponding querys in File ->
>> Options (similar to the browser tab or maybe a general "simple mode"
>> type idea).
>
> I'll look into it.

I figured out a way of detecting if a tab is visible, regardless of
whether it is currently selected, so with that info we can ensure we
only load the listviews that are currently visible (or are about to
become visible, if the tabset selection is changing). I also realised
that we were loading the three most expensive tabs twice every time
the selected object was changed(!), so even if all tabs are visible it
should be twice as fast as it was now.

I also cleaned up the code that does this, as it had become somewhat
spaghetti-like, and had duplication in a number of code paths.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company