added -Z option to prevent tables from being analyzed

main
stefanpetrea 2021-04-30 03:46:46 +03:00
parent 02b6fd4581
commit 13569c1808
3 changed files with 19 additions and 6 deletions

View File

@ -68,6 +68,7 @@ usage()
printf(_( " -X <tablespace> Specify the tablespace for the table's indexes.\n"
" This applies to the primary key, and the spatial index if\n"
" the -I flag is used.\n" ));
printf(_( " -Z Prevent tables from being analyzed.\n" ));
printf(_( " -? Display this help screen.\n" ));
printf( "\n" );
printf(_( " An argument of `--' disables further option processing.\n" ));
@ -102,7 +103,7 @@ main (int argc, char **argv)
set_loader_config_defaults(config);
/* Keep the flag list alphabetic so it's easy to see what's left. */
while ((c = pgis_getopt(argc, argv, "-acdeg:ikm:nps:t:wDGIN:ST:W:X:")) != EOF)
while ((c = pgis_getopt(argc, argv, "-acdeg:ikm:nps:t:wDGIN:ST:W:X:Z")) != EOF)
{
// can not do this inside the switch case
if ('-' == c)
@ -125,6 +126,10 @@ main (int argc, char **argv)
config->geography = 1;
break;
case 'Z':
config->analyze = 0;
break;
case 'S':
config->simple_geometries = 1;
break;

View File

@ -763,6 +763,7 @@ set_loader_config_defaults(SHPLOADERCONFIG *config)
config->quoteidentifiers = 0;
config->forceint4 = 0;
config->createindex = 0;
config->analyze = 1;
config->readshape = 1;
config->force_output = FORCE_OUTPUT_DISABLE;
config->encoding = strdup(ENCODING_DEFAULT);
@ -1925,13 +1926,17 @@ ShpLoaderGetSQLFooter(SHPLOADERSTATE *state, char **strfooter)
stringbuffer_aprintf(sb, "COMMIT;\n");
}
/* Always ANALYZE the resulting table, for better stats */
stringbuffer_aprintf(sb, "ANALYZE ");
if (state->config->schema)
if(state->config->analyze)
{
stringbuffer_aprintf(sb, "\"%s\".", state->config->schema);
/* Always ANALYZE the resulting table, for better stats */
stringbuffer_aprintf(sb, "ANALYZE ");
if (state->config->schema)
{
stringbuffer_aprintf(sb, "\"%s\".", state->config->schema);
}
stringbuffer_aprintf(sb, "\"%s\";\n", state->config->table);
}
stringbuffer_aprintf(sb, "\"%s\";\n", state->config->table);
/* Copy the string buffer into a new string, destroying the string buffer */
ret = (char *)malloc(strlen((char *)stringbuffer_getstring(sb)) + 1);

View File

@ -114,6 +114,9 @@ typedef struct shp_loader_config
/* 0 = no index, 1 = create index after load */
int createindex;
/* 0 = don't analyze tables , 1 = analyze tables */
int analyze;
/* 0 = load DBF file only, 1 = load everything */
int readshape;