提交 e6b92542 编写于 作者: T Tom Lane

Marginal speedup in RelationIsVisible and TypeIsVisible: avoid a redundant

cache lookup in the success case.  This won't help much for cases where
the given relation is far down the search path, but it does not hurt in
any cases either; and it requires only a little new code.  Per gripe from
Jim Nasby about slowness of \d with many tables.
上级 f59175d7
......@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.77 2005/08/01 04:03:54 tgl Exp $
* $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.78 2005/10/06 22:43:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -335,12 +335,28 @@ RelationIsVisible(Oid relid)
/*
* If it is in the path, it might still not be visible; it could
* be hidden by another relation of the same name earlier in the
* path. So we must do a slow check to see if this rel would be
* found by RelnameGetRelid.
* path. So we must do a slow check for conflicting relations.
*/
char *relname = NameStr(relform->relname);
ListCell *l;
visible = (RelnameGetRelid(relname) == relid);
visible = false;
foreach(l, namespaceSearchPath)
{
Oid namespaceId = lfirst_oid(l);
if (namespaceId == relnamespace)
{
/* Found it first in path */
visible = true;
break;
}
if (OidIsValid(get_relname_relid(relname, namespaceId)))
{
/* Found something else first in path */
break;
}
}
}
ReleaseSysCache(reltup);
......@@ -417,12 +433,31 @@ TypeIsVisible(Oid typid)
/*
* If it is in the path, it might still not be visible; it could
* be hidden by another type of the same name earlier in the path.
* So we must do a slow check to see if this type would be found
* by TypenameGetTypid.
* So we must do a slow check for conflicting types.
*/
char *typname = NameStr(typform->typname);
ListCell *l;
visible = (TypenameGetTypid(typname) == typid);
visible = false;
foreach(l, namespaceSearchPath)
{
Oid namespaceId = lfirst_oid(l);
if (namespaceId == typnamespace)
{
/* Found it first in path */
visible = true;
break;
}
if (SearchSysCacheExists(TYPENAMENSP,
PointerGetDatum(typname),
ObjectIdGetDatum(namespaceId),
0, 0))
{
/* Found something else first in path */
break;
}
}
}
ReleaseSysCache(typtup);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册