Since I wanted to know it, I extended explain to output the used (only the
first)
index on IndexScan.
An explain with this patch applied says:

template1=> explain select * from pg_class where oid=1;
NOTICE:  QUERY PLAN:
Index Scan using pg_class_oid_index on pg_class  (cost=2.03 size=1 width=74)
EXPLAIN

Does somebody want to add it to CVS please ?
Andreas

--- src/backend/commands/explain.c	Tue Mar  3 21:10:34 1998

+++
src/backend/commands/explain.c.orig	Thu Feb 26 05:30:58 1998

@@ -23,6
+23,7 @@

 #include <parser/parse_node.h>

 #include <optimizer/planner.h>


#include <access/xact.h>

+#include <utils/relcache.h>

 

 typedef struct
ExplainState

 {

@@ -117,6 +118,8 @@

 static void

 explain_outNode(StringInfo
str, Plan *plan, int indent, ExplainState *es)

 {

+	List
*l;

+	Relation	relation;

 	char	   *pname;

 	char
buf[1000];

 	int			i;

@@ -184,8 +187,12 @@


appendStringInfo(str, pname);

 	switch (nodeTag(plan))

 	{

-
case T_SeqScan:

 		case T_IndexScan:

+
appendStringInfo(str, " using ");

+			l = ((IndexScan *)
plan)->indxid;

+			relation =
RelationIdCacheGetRelation((int) lfirst(l));

+
appendStringInfo(str, (RelationGetRelationName(relation))->data);

+
case T_SeqScan:

 			if (((Scan *) plan)->scanrelid > 0)


{

 				RangeTblEntry *rte = nth(((Scan *)
plan)->scanrelid - 1, es->rtable);



Wed, 4 Mar 1998 11:02:02 +0100 
Zeugswetter Andreas SARZ <Andreas.Zeugswetter@telecom.at>
Feature: output index name in explain ...
Zeugswetter Andreas SARZ wrote:
> 
> Since I wanted to know it, I extended explain to output the used (only the
> first)
> index on IndexScan.
> An explain with this patch applied says:
> 
> template1=> explain select * from pg_class where oid=1;
> NOTICE:  QUERY PLAN:
> Index Scan using pg_class_oid_index on pg_class  (cost=2.03 size=1 width=74)

I like this. Any objections ?

Vadim

Wed, 25 Mar 1998 15:52:04 +0700
"Vadim B. Mikheev" <vadim@sable.krasnoyarsk.su>
Re: [HACKERS] Feature: output index name in explain ...
> 
> Zeugswetter Andreas SARZ wrote:
> > 
> > Since I wanted to know it, I extended explain to output the used (only the
> > first)
> > index on IndexScan.
> > An explain with this patch applied says:
> > 
> > template1=> explain select * from pg_class where oid=1;
> > NOTICE:  QUERY PLAN:
> > Index Scan using pg_class_oid_index on pg_class  (cost=2.03 size=1 width=74)
> 
> I like this. Any objections ?

Love it.

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Wed, 25 Mar 1998 09:46:38 -0500 (EST)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] Feature: output index name in explain ...