|
19 | 19 | * |
20 | 20 | * Copyright (c) 2001, PostgreSQL Global Development Group |
21 | 21 | * |
22 | | - * $Id: pgstat.c,v 1.1 2001/06/22 19:18:35 wieck Exp $ |
| 22 | + * $Id: pgstat.c,v 1.2 2001/06/29 16:29:37 wieck Exp $ |
23 | 23 | * ---------- |
24 | 24 | */ |
25 | 25 | #include <stdio.h> |
@@ -757,230 +757,6 @@ pgstat_initstats(PgStat_Info *stats, Relation rel) |
757 | 757 | } |
758 | 758 |
|
759 | 759 |
|
760 | | -/* ---------- |
761 | | - * pgstat_reset_heap_scan() - |
762 | | - * |
763 | | - * Called from heap_rescan() to reset the heap_scan_counted flag. |
764 | | - * Since the optimizer usually does a beginscan()/endscan() without |
765 | | - * really doing a scan, we cannot count those calls. We have to wait |
766 | | - * if after a beginscan() or rescan() really a call to the getnext() |
767 | | - * function happens. |
768 | | - * ---------- |
769 | | - */ |
770 | | -void |
771 | | -pgstat_reset_heap_scan(PgStat_Info *stats) |
772 | | -{ |
773 | | - if (stats->tabentry == NULL) |
774 | | - return; |
775 | | - |
776 | | - stats->heap_scan_counted = FALSE; |
777 | | -} |
778 | | - |
779 | | - |
780 | | -/* ---------- |
781 | | - * pgstat_count_heap_scan() - |
782 | | - * |
783 | | - * Called from heap_getnext() to tell us that now the relation |
784 | | - * really is scanned. |
785 | | - * ---------- |
786 | | - */ |
787 | | -void |
788 | | -pgstat_count_heap_scan(PgStat_Info *stats) |
789 | | -{ |
790 | | - if (stats->tabentry == NULL) |
791 | | - return; |
792 | | - |
793 | | - if (!stats->heap_scan_counted) |
794 | | - { |
795 | | - ((PgStat_TableEntry *)(stats->tabentry))->t_numscans++; |
796 | | - stats->heap_scan_counted = TRUE; |
797 | | - } |
798 | | -} |
799 | | - |
800 | | - |
801 | | -/* ---------- |
802 | | - * pgstat_count_heap_getnext() - |
803 | | - * |
804 | | - * Called from heap_getnext() whenever a valid tuple is returned |
805 | | - * from a sequential scan. The above cannot get combined into this, |
806 | | - * because if a heap scan didn't return any tuples, the scan itself |
807 | | - * would be missing in the stats. |
808 | | - * ---------- |
809 | | - */ |
810 | | -void |
811 | | -pgstat_count_heap_getnext(PgStat_Info *stats) |
812 | | -{ |
813 | | - if (stats->tabentry == NULL) |
814 | | - return; |
815 | | - |
816 | | - ((PgStat_TableEntry *)(stats->tabentry))->t_tuples_returned++; |
817 | | -} |
818 | | - |
819 | | - |
820 | | -/* ---------- |
821 | | - * pgstat_count_heap_fetch() - |
822 | | - * |
823 | | - * Called from heap_fetch() if this is caused by a heap lookup |
824 | | - * for an actually done index scan. |
825 | | - * ---------- |
826 | | - */ |
827 | | -void |
828 | | -pgstat_count_heap_fetch(PgStat_Info *stats) |
829 | | -{ |
830 | | - if (stats->tabentry == NULL) |
831 | | - return; |
832 | | - |
833 | | - ((PgStat_TableEntry *)(stats->tabentry))->t_tuples_fetched++; |
834 | | -} |
835 | | - |
836 | | - |
837 | | -/* ---------- |
838 | | - * pgstat_count_heap_insert() - |
839 | | - * |
840 | | - * Called from heap_insert(). |
841 | | - * ---------- |
842 | | - */ |
843 | | -void |
844 | | -pgstat_count_heap_insert(PgStat_Info *stats) |
845 | | -{ |
846 | | - if (stats->tabentry == NULL) |
847 | | - return; |
848 | | - |
849 | | - ((PgStat_TableEntry *)(stats->tabentry))->t_tuples_inserted++; |
850 | | -} |
851 | | - |
852 | | - |
853 | | -/* ---------- |
854 | | - * pgstat_count_heap_update() - |
855 | | - * |
856 | | - * Called from heap_update(). |
857 | | - * ---------- |
858 | | - */ |
859 | | -void |
860 | | -pgstat_count_heap_update(PgStat_Info *stats) |
861 | | -{ |
862 | | - if (stats->tabentry == NULL) |
863 | | - return; |
864 | | - |
865 | | - ((PgStat_TableEntry *)(stats->tabentry))->t_tuples_updated++; |
866 | | -} |
867 | | - |
868 | | - |
869 | | -/* ---------- |
870 | | - * pgstat_count_heap_delete() - |
871 | | - * |
872 | | - * Called from heap_delete(). |
873 | | - * ---------- |
874 | | - */ |
875 | | -void |
876 | | -pgstat_count_heap_delete(PgStat_Info *stats) |
877 | | -{ |
878 | | - if (stats->tabentry == NULL) |
879 | | - return; |
880 | | - |
881 | | - ((PgStat_TableEntry *)(stats->tabentry))->t_tuples_deleted++; |
882 | | -} |
883 | | - |
884 | | - |
885 | | -/* ---------- |
886 | | - * pgstat_reset_index_scan() - |
887 | | - * |
888 | | - * See pgstat_reset_heap_scan(). |
889 | | - * ---------- |
890 | | - */ |
891 | | -void |
892 | | -pgstat_reset_index_scan(PgStat_Info *stats) |
893 | | -{ |
894 | | - if (stats->tabentry == NULL) |
895 | | - return; |
896 | | - |
897 | | - stats->index_scan_counted = FALSE; |
898 | | -} |
899 | | - |
900 | | - |
901 | | -/* ---------- |
902 | | - * pgstat_count_index_scan() - |
903 | | - * |
904 | | - * See pgstat_count_heap_scan(). |
905 | | - * ---------- |
906 | | - */ |
907 | | -void |
908 | | -pgstat_count_index_scan(PgStat_Info *stats) |
909 | | -{ |
910 | | - if (stats->tabentry == NULL) |
911 | | - return; |
912 | | - |
913 | | - if (!stats->index_scan_counted) |
914 | | - { |
915 | | - ((PgStat_TableEntry *)(stats->tabentry))->t_numscans++; |
916 | | - stats->index_scan_counted = TRUE; |
917 | | - } |
918 | | -} |
919 | | - |
920 | | - |
921 | | -/* ---------- |
922 | | - * pgstat_reset_index_getnext() - |
923 | | - * |
924 | | - * See pgstat_count_heap_getnext(). |
925 | | - * ---------- |
926 | | - */ |
927 | | -void |
928 | | -pgstat_count_index_getnext(PgStat_Info *stats) |
929 | | -{ |
930 | | - if (stats->tabentry == NULL) |
931 | | - return; |
932 | | - |
933 | | - ((PgStat_TableEntry *)(stats->tabentry))->t_tuples_returned++; |
934 | | -} |
935 | | - |
936 | | - |
937 | | -/* ---------- |
938 | | - * pgstat_count_buffer_read() - |
939 | | - * |
940 | | - * Called from bufmgr.c when a buffer is looked up in the shared buffer |
941 | | - * cache. The real number of buffers read from the disk (or at least the |
942 | | - * OSs or drives cache) is this minus buffer_hit_count below. |
943 | | - * ---------- |
944 | | - */ |
945 | | -void |
946 | | -pgstat_count_buffer_read(PgStat_Info *stats, Relation rel) |
947 | | -{ |
948 | | - if (stats->tabentry == NULL) |
949 | | - { |
950 | | - if (stats->no_stats) |
951 | | - return; |
952 | | - pgstat_initstats(stats, rel); |
953 | | - if (stats->tabentry == NULL) |
954 | | - return; |
955 | | - } |
956 | | - |
957 | | - ((PgStat_TableEntry *)(stats->tabentry))->t_blocks_fetched++; |
958 | | -} |
959 | | - |
960 | | - |
961 | | -/* ---------- |
962 | | - * pgstat_count_buffer_hit() - |
963 | | - * |
964 | | - * Counts how many buffer per relation (or index) have been found |
965 | | - * in the buffer cache. |
966 | | - * ---------- |
967 | | - */ |
968 | | -void |
969 | | -pgstat_count_buffer_hit(PgStat_Info *stats, Relation rel) |
970 | | -{ |
971 | | - if (stats->tabentry == NULL) |
972 | | - { |
973 | | - if (stats->no_stats) |
974 | | - return; |
975 | | - pgstat_initstats(stats, rel); |
976 | | - if (stats->tabentry == NULL) |
977 | | - return; |
978 | | - } |
979 | | - |
980 | | - ((PgStat_TableEntry *)(stats->tabentry))->t_blocks_hit++; |
981 | | -} |
982 | | - |
983 | | - |
984 | 760 | /* ---------- |
985 | 761 | * pgstat_count_xact_commit() - |
986 | 762 | * |
|
0 commit comments