X-Original-To: pgsql-admin@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 03795475CED for ; Sun, 23 Feb 2003 11:50:00 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 82287-01 for ; Sun, 23 Feb 2003 11:49:49 -0500 (EST) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 59D96475A45 for ; Sun, 23 Feb 2003 11:37:36 -0500 (EST) Received: (qmail 1831 invoked from network); 23 Feb 2003 16:35:59 -0000 Received: from ns1.trade-india.com (HELO www.trade-india.com) (66.234.10.14) by infocom-236-129-del.trade-india.com with SMTP; 23 Feb 2003 16:35:59 -0000 Received: (qmail 8749 invoked by uid 99); 23 Feb 2003 16:37:59 -0000 Received: from 219.65.235.8 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Sun, 23 Feb 2003 22:07:59 +0530 (IST) Message-ID: <1042.219.65.235.8.1046018279.squirrel@mail.trade-india.com> Date: Sun, 23 Feb 2003 22:07:59 +0530 (IST) Subject: \d tablename with psql over slow links... From: To: X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal X-Mailer: SquirrelMail (version 1.2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/361 X-Sequence-Number: 7559 Hi. The \d tablename is too slow when its comes to usage over a dialup connecti= on. What i observed is that psql issues a sperate set of sql for getting default value of each attribute if it has. The number sqls increases as the size of table increases (no of attributes). the information abt the default values can also be got by using a subselect in the top level query which psql does to get list of attributes. over local/fast links it may not be significant problem , but for dial up connections it does. I observed that a table which used to take 16 secs with \d was only taking 6 secs if the query for default attribute values are shifted to top level q= uery in psql/describe.c ( function describeOneTableDetails ) . below is the diff for describe.c Any comments? [root@subho psql]# diff -B ../safepsql/describe.c describe.c 638a639 > unsigned int defaultcol =3D 5; 706a709,714 > > /* my code additions 1 */ > appendPQExpBuffer(&buf, ", (SELECT substring(adsrc for 128) FROM p= g_catalog.pg_attrdef=20 > WHERE adrelid =3D%s AND adnum =3D a.attnum ) " , oid );> /*= ends 1 */ > > 760,768d775 < PGresult *result; < < printfPQExpBuffer(&buf, < "SELECT s= ubstring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d\n"< = "WHERE d.adrelid =3D '%s' AND d.adnum =3D %s", < oid, PQge= tvalue(res, i, 4)); < < result =3D PSQLexec(buf.data, false); < 772d779 < strcat(cells[i * cols + 2], result ? PQgetv= alue(result, 0, 0) : "?"); 774c781,784 < PQclear(result); --- > if (verbose) > defaultcol =3D 6; > strcat(cells[i * cols + 2], PQgetvalue(res,= i, defaultcol ) ); > ----------------------------------------- Get your free web based email at trade-india.com. "India's Leading B2B eMarketplace.!" http://www.trade-india.com/