mirror of
https://github.com/postgres/postgres.git
synced 2025-08-24 09:27:52 +03:00
1. Run all pg_dump queries in single serializable transaction.
2. Get rid of locking when updating statistics in vacuum. 3. Use QuerySnapshot in COPY TO and call SetQuerySnashot in main tcop loop before FETCH and COPY TO.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.78 1999/05/26 12:55:10 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.79 1999/05/29 10:25:29 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -381,7 +381,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
int32 ntuples;
|
||||
TupleDesc tupDesc;
|
||||
|
||||
scandesc = heap_beginscan(rel, 0, SnapshotNow, 0, NULL);
|
||||
scandesc = heap_beginscan(rel, 0, QuerySnapshot, 0, NULL);
|
||||
|
||||
attr_count = rel->rd_att->natts;
|
||||
attr = rel->rd_att->attrs;
|
||||
@@ -1363,7 +1363,7 @@ CountTuples(Relation relation)
|
||||
|
||||
int i;
|
||||
|
||||
scandesc = heap_beginscan(relation, 0, SnapshotNow, 0, NULL);
|
||||
scandesc = heap_beginscan(relation, 0, QuerySnapshot, 0, NULL);
|
||||
|
||||
i = 0;
|
||||
while (HeapTupleIsValid(tuple = heap_getnext(scandesc, 0)))
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.104 1999/05/25 16:08:27 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.105 1999/05/29 10:25:30 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -93,7 +93,6 @@ static void vc_attrstats(Relation onerel, VRelStats *vacrelstats, HeapTuple tupl
|
||||
static void vc_bucketcpy(Form_pg_attribute attr, Datum value, Datum *bucket, int16 *bucket_len);
|
||||
static void vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *vacrelstats);
|
||||
static void vc_delhilowstats(Oid relid, int attcnt, int *attnums);
|
||||
static void vc_setpagelock(Relation rel, BlockNumber blkno);
|
||||
static VPageDescr vc_tidreapped(ItemPointer itemptr, VPageList vpl);
|
||||
static void vc_reappage(VPageList vpl, VPageDescr vpc);
|
||||
static void vc_vpinsert(VPageList vpl, VPageDescr vpnew);
|
||||
@@ -2221,7 +2220,8 @@ vc_bucketcpy(Form_pg_attribute attr, Datum value, Datum *bucket, int16 *bucket_l
|
||||
* tuple that's already on the page. The reason for this is that if
|
||||
* we updated these tuples in the usual way, then every tuple in pg_class
|
||||
* would be replaced every day. This would make planning and executing
|
||||
* historical queries very expensive.
|
||||
* historical queries very expensive. Note that we also don't use
|
||||
* any locking while doing updation.
|
||||
*/
|
||||
static void
|
||||
vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *vacrelstats)
|
||||
@@ -2257,7 +2257,6 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
||||
pfree(ctup);
|
||||
|
||||
/* overwrite the existing statistics in the tuple */
|
||||
vc_setpagelock(rd, ItemPointerGetBlockNumber(&(rtup.t_self)));
|
||||
pgcform = (Form_pg_class) GETSTRUCT(&rtup);
|
||||
pgcform->reltuples = num_tuples;
|
||||
pgcform->relpages = num_pages;
|
||||
@@ -2301,11 +2300,6 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
||||
/* overwrite the existing statistics in the tuple */
|
||||
if (VacAttrStatsEqValid(stats))
|
||||
{
|
||||
Buffer abuffer = scan->rs_cbuf;
|
||||
|
||||
vc_setpagelock(ad, ItemPointerGetBlockNumber(&atup->t_self));
|
||||
attp = (Form_pg_attribute) GETSTRUCT(atup);
|
||||
|
||||
if (stats->nonnull_cnt + stats->null_cnt == 0 ||
|
||||
(stats->null_cnt <= 1 && stats->best_cnt == 1))
|
||||
selratio = 0;
|
||||
@@ -2338,7 +2332,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
||||
* Invalidate the cache for the tuple and write the buffer
|
||||
*/
|
||||
RelationInvalidateHeapTuple(ad, atup);
|
||||
WriteNoReleaseBuffer(abuffer);
|
||||
WriteNoReleaseBuffer(scan->rs_cbuf);
|
||||
|
||||
/* DO PG_STATISTIC INSERTS */
|
||||
|
||||
@@ -2396,9 +2390,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
||||
*/
|
||||
RelationInvalidateHeapTuple(rd, &rtup);
|
||||
|
||||
WriteNoReleaseBuffer(buffer);
|
||||
|
||||
ReleaseBuffer(buffer);
|
||||
WriteBuffer(buffer);
|
||||
|
||||
heap_close(rd);
|
||||
}
|
||||
@@ -2449,12 +2441,6 @@ vc_delhilowstats(Oid relid, int attcnt, int *attnums)
|
||||
heap_close(pgstatistic);
|
||||
}
|
||||
|
||||
static void
|
||||
vc_setpagelock(Relation rel, BlockNumber blkno)
|
||||
{
|
||||
LockPage(rel, blkno, ExclusiveLock);
|
||||
}
|
||||
|
||||
/*
|
||||
* vc_reappage() -- save a page on the array of reapped pages.
|
||||
*
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.117 1999/05/26 12:55:55 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.118 1999/05/29 10:25:30 vadim Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@@ -73,6 +73,8 @@
|
||||
#include "utils/rel.h"
|
||||
#include "utils/ps_status.h"
|
||||
#include "utils/temprel.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
#include "../backend/parser/parse.h"
|
||||
|
||||
#ifdef NOT_USED
|
||||
#include "nodes/relation.h"
|
||||
@@ -715,6 +717,13 @@ pg_exec_query_dest(char *query_string, /* string to execute */
|
||||
else if (Verbose)
|
||||
TPRINTF(TRACE_VERBOSE, "ProcessUtility");
|
||||
|
||||
/*
|
||||
* We have to set query SnapShot in the case of FETCH or COPY TO.
|
||||
*/
|
||||
if (nodeTag(querytree->utilityStmt) == T_FetchStmt ||
|
||||
(nodeTag(querytree->utilityStmt) == T_CopyStmt &&
|
||||
((CopyStmt *)(querytree->utilityStmt))->direction != FROM))
|
||||
SetQuerySnapshot();
|
||||
ProcessUtility(querytree->utilityStmt, dest);
|
||||
}
|
||||
else
|
||||
@@ -1527,7 +1536,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
puts("\nPOSTGRES backend interactive interface ");
|
||||
puts("$Revision: 1.117 $ $Date: 1999/05/26 12:55:55 $\n");
|
||||
puts("$Revision: 1.118 $ $Date: 1999/05/29 10:25:30 $\n");
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
|
Reference in New Issue
Block a user