forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite0e4ebe
committed
Improve handling of utility statements containing plannable statements.
When tracking nested statements, contrib/pg_stat_statements formerlydouble-counted the execution costs of utility statements that directlycontain an executable statement, such as EXPLAIN and DECLARE CURSOR.This was not obvious since the ProcessUtility and Executor hookswould each add their measured costs to the same stats table entry.However, with the new implementation that hashes utility and plannablestatements differently, this showed up as seemingly-duplicate statsentries. Fix that by disabling the Executor hooks when the query has aqueryId of zero, which was the case already for such statements but is nowmore clearly specified in the code. (The zero queryId was causing problemsanyway because all such statements would add to a single bogus entry.)The PREPARE/EXECUTE case still results in counting the same executionin two different stats table entries, but it should be much less surprisingto users that there are two entries in such cases.In passing, include a CommonTableExpr's ctename in the query hash.I had left it out originally on the grounds that we wanted to omit allinessential aliases, but since RTE_CTE RTEs are hashing their referencednames, we'd better hash the CTE names too to make sure we don't hashsemantically different queries the same.1 parent2005b77 commite0e4ebe
1 file changed
+29
-8
lines changedLines changed: 29 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
602 | 602 |
| |
603 | 603 |
| |
604 | 604 |
| |
605 |
| - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
606 | 613 |
| |
| 614 | + | |
| 615 | + | |
607 | 616 |
| |
| 617 | + | |
608 | 618 |
| |
609 | 619 |
| |
610 | 620 |
| |
| |||
618 | 628 |
| |
619 | 629 |
| |
620 | 630 |
| |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
621 | 638 |
| |
622 | 639 |
| |
623 | 640 |
| |
| |||
649 | 666 |
| |
650 | 667 |
| |
651 | 668 |
| |
652 |
| - | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
653 | 675 |
| |
654 | 676 |
| |
655 | 677 |
| |
| |||
719 | 741 |
| |
720 | 742 |
| |
721 | 743 |
| |
722 |
| - | |
723 |
| - | |
724 |
| - | |
725 |
| - | |
726 |
| - | |
727 |
| - | |
| 744 | + | |
728 | 745 |
| |
| 746 | + | |
| 747 | + | |
729 | 748 |
| |
730 | 749 |
| |
731 | 750 |
| |
| |||
1794 | 1813 |
| |
1795 | 1814 |
| |
1796 | 1815 |
| |
| 1816 | + | |
| 1817 | + | |
1797 | 1818 |
| |
1798 | 1819 |
| |
1799 | 1820 |
| |
|
0 commit comments
Comments
(0)