diff --git a/pgadmin/ctl/explainCanvas.cpp b/pgadmin/ctl/explainCanvas.cpp
index c719865..7e25afa 100644
--- a/pgadmin/ctl/explainCanvas.cpp
+++ b/pgadmin/ctl/explainCanvas.cpp
@@ -25,7 +25,7 @@ END_EVENT_TABLE()
 
 
 ExplainCanvas::ExplainCanvas(wxWindow *parent)
-	: wxShapeCanvas(parent)
+	: wxShapeCanvas(parent), rootShape(NULL)
 {
 	SetDiagram(new wxDiagram);
 	GetDiagram()->SetCanvas(this);
@@ -42,6 +42,7 @@ ExplainCanvas::~ExplainCanvas()
 void ExplainCanvas::Clear()
 {
 	GetDiagram()->DeleteAllShapes();
+	rootShape = NULL;
 }
 
 
@@ -49,7 +50,13 @@ void ExplainCanvas::SetExplainString(const wxString &str)
 {
 	Clear();
 
-	ExplainShape *last = 0;
+	// We can have multiple plans in a single explain string
+	// Add a empty root shape, which will never get drawn, but it will help us
+	// to keep track of all these plans
+	rootShape = ExplainShape::Create(0, NULL, wxEmptyString);
+	AddShape(rootShape);
+
+	ExplainShape *last = rootShape;
 	int maxLevel = 0;
 
 	wxStringTokenizer lines(str, wxT("\n"));
@@ -82,11 +89,11 @@ void ExplainCanvas::SetExplainString(const wxString &str)
 		}
 		while (lines.HasMoreTokens());
 
-		long level = (tmp.Length() - line.Length() + 4) / 6;
+		long level = ((tmp.Length() - line.Length() + 4) / 6) + 1;
 
 		if (last)
 		{
-			if (level)
+			if (level != 1)
 			{
 				if (line.Left(4) == wxT("->  "))
 					line = line.Mid(4);
@@ -97,7 +104,7 @@ void ExplainCanvas::SetExplainString(const wxString &str)
 				}
 			}
 
-			while (last && level <= last->GetLevel())
+			while (last != rootShape && level <= last->GetLevel())
 				last = last->GetUpper();
 		}
 
@@ -112,8 +119,6 @@ void ExplainCanvas::SetExplainString(const wxString &str)
 		if (level > maxLevel)
 			maxLevel = level;
 
-		if (!last)
-			rootShape = s;
 		last = s;
 	}
 
@@ -148,9 +153,14 @@ void ExplainCanvas::SetExplainString(const wxString &str)
 			s->SetY(upper->GetY() + upper->usedShapes * yoffs);
 			upper->usedShapes += s->totalShapes;
 
-			wxLineShape *l = new ExplainLine(s, upper);
-			l->Show(true);
-			AddShape(l);
+			// We don't require to draw a line from the root shape to its
+			// childrens
+			if (upper != rootShape)
+			{
+				wxLineShape *l = new ExplainLine(s, upper);
+				l->Show(true);
+				AddShape(l);
+			}
 		}
 		else
 		{
diff --git a/pgadmin/ctl/explainShape.cpp b/pgadmin/ctl/explainShape.cpp
index 2e49215..7d9da14 100644
--- a/pgadmin/ctl/explainShape.cpp
+++ b/pgadmin/ctl/explainShape.cpp
@@ -71,6 +71,7 @@ ExplainShape::ExplainShape(const wxImage &bmp, const wxString &description, long
 	kidCount = 0;
 	totalShapes = 0;
 	usedShapes = 0;
+	m_rootShape = false;
 }
 
 
@@ -119,6 +120,10 @@ void ExplainShape::OnDraw(wxDC &dc)
 	if (!bmp.Ok())
 		return;
 
+	// We do not draw the root shape
+	if (m_rootShape)
+		return;
+
 	int x, y;
 	x = WXROUND(m_xpos - bmp.GetWidth() / 2.0);
 	y = WXROUND(m_ypos - GetHeight() / 2.0);
@@ -180,6 +185,29 @@ ExplainShape *ExplainShape::Create(long level, ExplainShape *last, const wxStrin
 	else
 		descr = str;
 
+	// Requested an empty shape, which can be treated as a root shape
+	if (level == 0)
+	{
+		s = new ExplainShape(*ex_unknown_png_img, wxEmptyString);
+		s->SetDraggable(false);
+		s->m_rootShape = true;
+		s->level = level;
+		int w = 50, h = 20;
+
+		wxBitmap &bmp = s->GetBitmap();
+		if (w < bmp.GetWidth())
+			w = bmp.GetWidth();
+
+		s->SetHeight(bmp.GetHeight() + BMP_BORDER + h);
+		s->SetWidth(w);
+
+		s->upperShape = NULL;
+		s->kidNo = 0;
+
+		return s;
+	}
+
+
 	// possible keywords can be found in postgresql/src/backend/commands/explain.c
 
 	if (token == wxT("Total"))              return 0;
diff --git a/pgadmin/include/ctl/explainCanvas.h b/pgadmin/include/ctl/explainCanvas.h
index bffd50b..3ae2102 100644
--- a/pgadmin/include/ctl/explainCanvas.h
+++ b/pgadmin/include/ctl/explainCanvas.h
@@ -102,6 +102,7 @@ protected:
 	int kidCount, kidNo;
 	int totalShapes; // horizontal space usage by shape and its kids
 	int usedShapes;
+	bool m_rootShape;
 
 	friend class ExplainCanvas;
 	friend class ExplainText;
