1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

Make bitmap heap scans show exact/lossy block info in EXPLAIN ANALYZE.

Etsuro Fujita
This commit is contained in:
Robert Haas
2014-01-13 14:42:16 -05:00
parent c3ccc9ee58
commit 2bb1f14b89
3 changed files with 43 additions and 1 deletions

View File

@ -85,6 +85,8 @@ static void show_sort_group_keys(PlanState *planstate, const char *qlabel,
List *ancestors, ExplainState *es);
static void show_sort_info(SortState *sortstate, ExplainState *es);
static void show_hash_info(HashState *hashstate, ExplainState *es);
static void show_tidbitmap_info(BitmapHeapScanState *planstate,
ExplainState *es);
static void show_instrumentation_count(const char *qlabel, int which,
PlanState *planstate, ExplainState *es);
static void show_foreignscan_info(ForeignScanState *fsstate, ExplainState *es);
@ -1250,7 +1252,13 @@ ExplainNode(PlanState *planstate, List *ancestors,
if (((BitmapHeapScan *) plan)->bitmapqualorig)
show_instrumentation_count("Rows Removed by Index Recheck", 2,
planstate, es);
/* FALL THRU */
show_scan_qual(plan->qual, "Filter", planstate, ancestors, es);
if (plan->qual)
show_instrumentation_count("Rows Removed by Filter", 1,
planstate, es);
if (es->analyze)
show_tidbitmap_info((BitmapHeapScanState *) planstate, es);
break;
case T_SeqScan:
case T_ValuesScan:
case T_CteScan:
@ -1878,6 +1886,29 @@ show_hash_info(HashState *hashstate, ExplainState *es)
}
}
/*
* If it's EXPLAIN ANALYZE, show exact/lossy pages for a BitmapHeapScan node
*/
static void
show_tidbitmap_info(BitmapHeapScanState *planstate, ExplainState *es)
{
if (es->format != EXPLAIN_FORMAT_TEXT)
{
ExplainPropertyLong("Exact Heap Blocks", planstate->exact_pages, es);
ExplainPropertyLong("Lossy Heap Blocks", planstate->lossy_pages, es);
}
else
{
appendStringInfoSpaces(es->str, es->indent * 2);
appendStringInfoString(es->str, "Heap Blocks:");
if (planstate->exact_pages > 0)
appendStringInfo(es->str, " exact=%ld", planstate->exact_pages);
if (planstate->lossy_pages > 0)
appendStringInfo(es->str, " lossy=%ld", planstate->lossy_pages);
appendStringInfoChar(es->str, '\n');
}
}
/*
* If it's EXPLAIN ANALYZE, show instrumentation information for a plan node
*