Add rudimentary ANALYZE support

pull/1013/head
Jason Petersen 2016-12-13 10:47:07 -07:00
parent 210c840d14
commit bcfedac399
No known key found for this signature in database
GPG Key ID: 9F1D3510D110ABA9
3 changed files with 29 additions and 9 deletions

View File

@ -377,11 +377,7 @@ multi_ProcessUtility(Node *parsetree,
{
VacuumStmt *vacuumStmt = (VacuumStmt *) parsetree;
/* must check fields to know whether actually a vacuum */
if (vacuumStmt->options | VACOPT_VACUUM)
{
ProcessVacuumStmt(vacuumStmt, queryString);
}
ProcessVacuumStmt(vacuumStmt, queryString);
}
}
@ -989,6 +985,13 @@ DeparseVacuumStmtPrefix(VacuumStmt *vacuumStmt)
);
const int vacuumFlags = vacuumStmt->options;
if (!(vacuumStmt->options & VACOPT_VACUUM))
{
appendStringInfoString(vacuumPrefix, "ANALYZE ");
return vacuumPrefix;
}
appendStringInfoString(vacuumPrefix, "VACUUM ");
if (!(vacuumFlags & supportedFlags))

View File

@ -83,9 +83,9 @@ SELECT master_create_worker_shards('dustbunnies', 1, 2);
-- add some data to the distributed table
\copy dustbunnies from stdin with csv
-- delete all rows from the shard, then run VACUUM against the table on the master
DELETE FROM dustbunnies;
-- run VACUUM and ANALYZE against the table on the master
VACUUM dustbunnies;
ANALYZE dustbunnies;
-- update statistics, then verify that the four dead rows are gone
\c - - - :worker_1_port
SELECT pg_sleep(.500);
@ -100,3 +100,9 @@ SELECT pg_stat_get_vacuum_count('dustbunnies_990002'::regclass);
1
(1 row)
SELECT pg_stat_get_analyze_count('dustbunnies_990002'::regclass);
pg_stat_get_analyze_count
---------------------------
1
(1 row)

View File

@ -56,11 +56,22 @@ SELECT master_create_worker_shards('dustbunnies', 1, 2);
4,roger
\.
-- delete all rows from the shard, then run VACUUM against the table on the master
DELETE FROM dustbunnies;
-- run VACUUM and ANALYZE against the table on the master
VACUUM dustbunnies;
ANALYZE dustbunnies;
-- update statistics, then verify that the four dead rows are gone
\c - - - :worker_1_port
SELECT pg_sleep(.500);
SELECT pg_stat_get_vacuum_count('dustbunnies_990002'::regclass);
SELECT pg_stat_get_analyze_count('dustbunnies_990002'::regclass);
-- try a mixed VACUUM ANALYZE
\c - - - :master_port
VACUUM (FULL, ANALYZE) dustbunnies;
-- update statistics, then verify that the four dead rows are gone
\c - - - :worker_1_port
SELECT pg_sleep(.500);
SELECT * FROM pg_stat_all_tables WHERE relid = 'dustbunnies_990002'::regclass;